From 5888e7a08e60d04695213cefb74aa7d62719b93e Mon Sep 17 00:00:00 2001 From: ynunokawa Date: Wed, 8 Jun 2016 12:22:28 +0900 Subject: [PATCH] minor change --- src/L.esri.WebMap.js | 90 ++++++++++++++++++++--------------------- test/layer-control.html | 2 + 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/src/L.esri.WebMap.js b/src/L.esri.WebMap.js index 7a0265b..74643a0 100644 --- a/src/L.esri.WebMap.js +++ b/src/L.esri.WebMap.js @@ -600,51 +600,51 @@ L.esri.WebMap = L.Evented.extend({ var labelingInfo = layer.layerDefinition.drawingInfo.labelingInfo; var labelText = window.webmap._generateLabel(geojson.properties, labelingInfo); console.log(labelText); - // with Leaflet.label - //f.bindLabel(labelText, { noHide: true }).showLabel(); - - console.log(geojson); - console.log(l); - var labelPos; - var labelClassName; - if(l.feature.geometry.type === 'Point') { - labelPos = l.feature.geometry.coordinates; - labelClassName = 'point-label'; - } - else if(l.feature.geometry.type === 'LineString') { - console.log(l.feature.geometry.coordinates); - var c = l.feature.geometry.coordinates; - var centralKey = Math.round(c.length/2); - console.log(c[centralKey]); - labelPos = c[centralKey].reverse(); - labelClassName = 'path-label'; - } - else if(l.feature.geometry.type === 'MultiLineString') { - console.log(l.feature.geometry.coordinates); - var c = l.feature.geometry.coordinates; - var centralKey = Math.round(c.length/2); - var c2 = c[centralKey]; - var centralKey = Math.round(c2.length/2); - console.log(c2[centralKey]); - labelPos = c2[centralKey].reverse(); - labelClassName = 'path-label'; - } - else { - labelPos = l.getBounds().getCenter(); - console.log(labelPos); - labelClassName = 'path-label'; - } - // without Leaflet.label - var label = L.marker(labelPos, { - zIndexOffset: 1, - icon: L.divIcon({ - iconSize: null, - className: labelClassName, - html: '
' + labelText + '
' - }) - }); - - labelsLayer.addLayer(label); + // with Leaflet.label + //f.bindLabel(labelText, { noHide: true }).showLabel(); + + console.log(geojson); + console.log(l); + var labelPos; + var labelClassName; + if(l.feature.geometry.type === 'Point') { + labelPos = l.feature.geometry.coordinates; + labelClassName = 'point-label'; + } + else if(l.feature.geometry.type === 'LineString') { + console.log(l.feature.geometry.coordinates); + var c = l.feature.geometry.coordinates; + var centralKey = Math.round(c.length/2); + console.log(c[centralKey]); + labelPos = c[centralKey].reverse(); + labelClassName = 'path-label'; + } + else if(l.feature.geometry.type === 'MultiLineString') { + console.log(l.feature.geometry.coordinates); + var c = l.feature.geometry.coordinates; + var centralKey = Math.round(c.length/2); + var c2 = c[centralKey]; + var centralKey = Math.round(c2.length/2); + console.log(c2[centralKey]); + labelPos = c2[centralKey].reverse(); + labelClassName = 'path-label'; + } + else { + labelPos = l.getBounds().getCenter(); + console.log(labelPos); + labelClassName = 'path-label'; + } + // without Leaflet.label + var label = L.marker(labelPos, { + zIndexOffset: 1, + icon: L.divIcon({ + iconSize: null, + className: labelClassName, + html: '
' + labelText + '
' + }) + }); + + labelsLayer.addLayer(label); } } }); diff --git a/test/layer-control.html b/test/layer-control.html index 2581ed4..4fece62 100644 --- a/test/layer-control.html +++ b/test/layer-control.html @@ -19,6 +19,8 @@ + +