0
我正在使用OpenStreetMap處理地圖網站,而我正在使用圖像標記而不是默認的標記。當放大或縮小地圖時,第一個問題,標記的位置稍微改變...所以我使用L.point設置錨點。然而,該鏈式反應發生也流行起來,它通過這個圖象描述:單張OSM標記彈出框定位
彈出覆蓋的標記,並且所述定位看起來不正確。任何建議如何修補彈出點?這裏是我的代碼:
var locations = data;
for (var i=0; i < locations.length; i++) {
if (locations[i][0] == 'panic') {
var icon = L.icon({iconUrl:"{{asset('assets/splash4.gif')}}", iconAnchor: new L.Point(36,41) });
var marker = L.marker([locations[i][1], locations[i][2]], {icon: icon});
marker.bindPopup(locations[i][5] + " <br>" + locations[i][6] + " <br>" + locations[i][7] + " <br><br>" + locations[i][3] + " <br>" + locations[i][4]).addTo(map);
if(i == locations.length - 1){
map.setView(new L.LatLng(locations[i][1], locations[i][2]), 18);
marker.bindPopup(locations[i][5] + " <br>" + locations[i][6] + " <br>" + locations[i][7] + " <br><br>" + locations[i][3] + " <br>" + locations[i][4]).openPopup().addTo(map);
}
} else {
var icon2 = L.icon({iconUrl:"{{asset('assets/opmarkerblue1.png')}}", iconAnchor: new L.Point(0,32)});
var marker = L.marker([locations[i][1], locations[i][2]], {icon: icon2});
marker.bindPopup(locations[i][5] + " <br>" + locations[i][6] + " <br>" + locations[i][7] + " <br><br>" + locations[i][3] + " <br>" + locations[i][4]).addTo(map);
}
}
任何幫助表示讚賞。