javascript - Leaflet/mapbox popups on markers -


i'm trying grab locations database , show them on map. markers show need them to, when bind popups them, error uncaught typeerror: failed execute 'appendchild' on 'node': parameter 1 not of type 'node'.

this js:

var map = l.map('map').setview([42.351776, -71.061371], 14);  l.mapbox.accesstoken = 'token'; l.tilelayer('https://{s}.tiles.mapbox.com//{z}/{x}/{y}.png?access_token=' + l.mapbox.accesstoken, { attribution: '<a href="http://www.mapbox.com/about/maps/" target="_blank">terms &amp; feedback</a>' }).addto(map);  $.get( '/events.json', function( data ) {   (i=0; i<data.length; i++) {     var coordinatesarray =  [data[i].latitude, data[i].longitude];     `var marker = l.marker([coordinatesarray[0],coordinatesarray[1]]).addto(map);`      marker.bindpopup("<h1>" + data.title + "</h1>");   } }); 

it seems work if load 1 marker popup, when try iterate through objects, starts give me error.

i think need drop backticks around marker creation, , include current index when accessing title.so instead of data.title, use data[i].title.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -