admin管理员组文章数量:1431006
I have notice that my leaflet markers are "not staying put" on a given lat/lon. When I zoom in on the map, the marker moves to adjust and take the correct position. When I zoom out, it goes to a different position. It'snot static on the position. How can I fix this ?
There is nothing special about my marker. below is how I built it
var LeafIcon = L.Icon.extend({
options: {
iconSize: [12, 15],
shadowSize: [30, 40],
iconAnchor: [11, 70],
shadowAnchor: [2, 42],
popupAnchor: [-3, -40]
}
});
var map_icon = new LeafIcon({iconUrl: 'icon_marker.png'});
var marker;
marker = L.marker([my_lat, my_lon], {icon: map_icon});
marker.addTo(map);
marker.bindPopup("My markers' popup");
I have notice that my leaflet markers are "not staying put" on a given lat/lon. When I zoom in on the map, the marker moves to adjust and take the correct position. When I zoom out, it goes to a different position. It'snot static on the position. How can I fix this ?
There is nothing special about my marker. below is how I built it
var LeafIcon = L.Icon.extend({
options: {
iconSize: [12, 15],
shadowSize: [30, 40],
iconAnchor: [11, 70],
shadowAnchor: [2, 42],
popupAnchor: [-3, -40]
}
});
var map_icon = new LeafIcon({iconUrl: 'icon_marker.png'});
var marker;
marker = L.marker([my_lat, my_lon], {icon: map_icon});
marker.addTo(map);
marker.bindPopup("My markers' popup");
Share
Improve this question
edited Jun 14, 2016 at 7:59
tsauerwein
6,0813 gold badges41 silver badges50 bronze badges
asked Jun 14, 2016 at 0:05
Jason KrsJason Krs
7142 gold badges10 silver badges30 bronze badges
0
1 Answer
Reset to default 6The symptom you describe is typical of incorrect iconAnchor
setting.
It is strange that your iconAnchor
is outside iconSize
.
To make sure your settings are properly defined, you could add an extra marker with default icon at the same lat/lng coordinates, and see if your custom icon tip is at the same position.
本文标签: javascriptLeaflet Marker not static on positionStack Overflow
版权声明:本文标题:javascript - Leaflet Marker not static on position - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745562663a2663566.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论