map - LeafletJS markers move on zoom -


using leafletjs ace, until :p don't have json object or anything, taking values out of html (title, latlng) , creating markers. works ok, there issue plotting of them. when map zoomed in seem ok, when zoom out (like map initially), way off. move on zoom.

so, doing wrong?

http://jsbin.com/edegox/1 http://jsbin.com/edegox/1/edit

cheers tom

the solution quite simple. leads should have posted it.

when markers moving around map it's because map doesn't know size of marker and/or doesn't know point of marker marks location.

your marker icon code might this:

var locationicon = l.icon({iconurl:'location_marker_icon.png'}); 

now, let's suppose image 24px wide , 36px tall. keep marker moving around, specify size of marker, , "anchor point"...

var locationicon = l.icon({                            iconurl:'location_marker_icon.png',                            iconsize: [24,36],                            iconanchor: [12,36]                           }); 

this make center pixel on bottom represent exact lat/lng point specified marker for, , keep anchored there!


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -