Custom icon Marker moves with zoom
See original GitHub issueHi I am new to leaflet. I am trying to add a custom marker similar to the custom icon sample here: http://leaflet.cloudmade.com/examples/custom-icons.html
When I zoom out the markers move away from the actual point at which the marker is placed. Here is my code, very simple: var map = L.map(‘map’).setView([51.5, -0.09], 13); L.tileLayer(‘http://{s}.tile.cloudmade.com/{key}/22677/256/{z}/{x}/{y}.png’, { attribution: ‘Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade’, key: ‘BC9A493B41014CAABB98F0471D759707’ }).addTo(map);
var icon = new L.Icon({iconUrl: 'map_pin.png'});
L.marker([51.5, -0.09], {icon: icon}).bindPopup("I am a green leaf.").addTo(map);
though I have tried a number of other things. This was brought up in issue #371. The author said he fixed it but did not provide the fix. Please help
Thanks, Sam
Issue Analytics
- State:
- Created 11 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
LeafletJS markers move on zoom - map - Stack Overflow
The solution to this is quite simple. Leads should have posted it. when your markers are moving around your map it's because the...
Read more >Markers change position when the map is zoomed
There are mainly 2 reason why the marker (mostly customized icons) on the map move its position when zoomed out. You are using...
Read more >How can I prevent Leaflet from moving my marker while ...
Therefore, when zooming in/out, your actual icon "tip" (which is at bottom center) will "move" relatively to that position.
Read more >Controlling Zoom and Pan | Maps JavaScript API
Users can zoom the map by clicking the zoom controls. They can also zoom and pan by using two-finger movements on the map...
Read more >Marker position moves with zoom - SiteOrigin
It is at the correct position when zoomed in to the maximum level, however as you zoom out the icon gets progressively further...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to also specify iconSize and iconAnchor, like in the tutorial.
@IvanSanchez look at this,please https://github.com/Leaflet/Leaflet/issues/895#issuecomment-1185630452