0
我試圖從我的數據庫中獲取位置並在地圖上顯示它們。該標記顯示了,我需要他們,但是當我結合我的彈出窗口給他們,我得到的錯誤Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
標記上的傳單/地圖框彈出窗口
這是我的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 & Feedback</a>'
}).addTo(map);
$.get('/events.json', function(data) {
for (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>");
}
});
這似乎工作,如果我只是加載一個標記彈出,但是當我嘗試遍歷對象時,它開始給我錯誤。