Let's say I have a bunch of markers (more than 100) I would add this: using I could so I will go about how to add all of those markers in a new layer (so I can turn them on / off)
module.exports = [{value: 'Varrock', LNG: 22.5, lat: -15.52249812756166 popular: 1} {value: 'Lumbridge', LNG: 25.9661865234375, lat: -43.644025847699496 popular: 1 }, {value: "Math, LNG: -4.0924072265625, lat: -5.714379819235291} {value:" Edgeville, LNG: 2.4884033203125, lat: -6.0094592380595495 popular: 1} {value: "Varrock Palace, LNG: 22 .41, 21, 9, 375, Latitude: -6.882800241767556} {Value: 'Digsite', LNG: 46. 43701171875, Lat: -17.266727823520508} {value: "River Salve, LNG: 54.9 31,640,625, Lat: -14.083301314706778} {value:" Morytania 'LNG: 64.6105 9 5703125, Lat: -13.501814172428656} {Value: 'Mort Myre Swamp', LNG: 59.820556640625, Lat: -22.740723091194727}]; browser to get it that is so, I do:
var location = required ( './ places'); What would be the best way to add them to LayerGroup () ? I mean, because on fairy = L.layerGroup tax ([one, two, three ...]);. get tedious hand
Monday, 15 March 2010
JavaScript - leaflet, adding a bunch of markers -
How about an empty l? By adding layer group , looping on your array and adding to that layer?
var locations = []; Var layer = L. Layer Group () AddTo (map); Locations.forEach (function (location) {L. marker ([location.lat, location.lng]) .bindopop (location.value) .addTo (layer);}); Examples of working on the planker:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment