javascript - Labels on features - ajax call -


i using leaflet 0.7 , want add static label using leaflet.label plugin.

i data ajax call. not sure put oneachfeature function populate labels. relatively new javascript , think got bit confused on one.

this code works long use layer.bindlabel('static label'). cannot populate data ajax call. know layer created before ajax call , not have access data. how can arrange code populate label data ajax call?

any appreciated

var pointlayer= new l.geojson(null, {     pointtolayer: function (feature, latlng) {         return l.marker(latlng, {icon: sandicon});         },         oneachfeature: function (feature, layer) {                 layer.bindlabel(feature.properties.id, //dynamic label                     {nohide:true,direction:'auto'});         },     oneachfeature: function (feature, layer) {             layer.bindpopup('test' + feature.properties.id);     } }).addto(map);  $.ajax({     url: "url",     datatype: 'jsonp',     cache: false,     jsonpcallback: 'getpoint',     success: handlepoint,  });  function handlepoint(data) {     pointlayer.adddata(data);  }; 

you have bind label marker created in pointtolayer

edit: not error

i not sure went wrong left working example here:

https://github.com/yafred/ajax-geojson-and-labels (source)

https://yafred.github.io/ajax-geojson-and-labels/ (web)

note: l.geojson leaflet 1.0, l.geojson leaflet 0.7


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -