using Leaflet.Label with GeoJSON points -


there numerous references leaflet.label working fine geojson points, i've yet find 1 example.
here's i've tried far:

//add labels layer var labelstyle = {     color: '#ccc',     opacity: 1 };  var labelmarkeroptions = {         opacity: 0,         fillopacity: 0 };  var labellayer = l.geojson(labels, {         pointtolayer: function (feature, latlng) {                 return l.marker(latlng, labelmarkeroptions);         },         oneachfeature: function (feature, layer) {                 layer.bindlabel(feature.properties.name, {nohide:true});         } }); labellayer.eachlayer(function(l) {l.showlabel();}); map.addlayer(labellayer); layercontrol.addoverlay(labellayer, 'site labels'); 

this adds layer of points, default larkers, , no labels. can provide.

if want show label, return l.circlemarker instead of l.marker:

pointtolayer: function (feature, latlng) {     return l.circlemarker(latlng, labelmarkeroptions); }, 

if need l.marker other reason, bind label directly marker:

pointtolayer: function (feature, latlng) {     return l.marker(latlng, labelmarkeroptions).bindlabel(feature.properties.name, {nohide:true}); }, 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -