Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
ynunokawa committed Jun 8, 2016
1 parent a4c74c3 commit 5888e7a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 45 deletions.
90 changes: 45 additions & 45 deletions src/L.esri.WebMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<div>' + labelText + '</div>'
})
});
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: '<div>' + labelText + '</div>'
})
});

labelsLayer.addLayer(label);
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions test/layer-control.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

<!-- Load Heatmap Feature Layer from CDN -->
<script src="https://cdn.jsdelivr.net/leaflet.esri.heatmap-feature-layer/2.0.0-beta.1/esri-leaflet-heatmap-feature-layer.js"></script>

<!-- Load TextPath from GitHub -->

<!-- Load Vector Icon from GitHub -->
<script src="https://muxlab.github.io/Leaflet.VectorIcon/L.VectorIcon.js"></script>
Expand Down

0 comments on commit 5888e7a

Please sign in to comment.