Note that there are some explanatory texts on larger screens.

plurals
  1. POopenlayers marker moveTo only accurate at a specific zoom level
    text
    copied!<p>I have been working on a way for users to move a marker without dragging. Basically, the user clicks on the marker and it opens the info window bubble. In the bubble is a link to a javascript function that sets a click event on the map. When the user clicks somewhere on the map it is supposed to move the marker to the point clicked.</p> <p>In my map, I have 18 zoom levels. At zoom level 15, this process works perfectly. If I zoom in AFTER clicking once, the marker still moves to exactly where I click. But then, if I refresh and start over at zoom level 16 and try to click somewhere, the marker is moved to a position higher and more to the left. Repeating this process at higher zoom levels, the marker is moved even further up and to the left on the map (in distance).</p> <p>Doing the above at zoom levels lower than 15 work just fine as well.</p> <p>Here's a snippet of the code:</p> <pre><code>lmLayer = new OpenLayers.Layer.Markers("Landmark Creation"); map.addLayer(lmLayer); var marker = landmark['landmark_1234'];// this just pulls the marker out of storage map.events.register("click", lmLayer, function(evt){ var pixel = new OpenLayers.Pixel(evt.clientX,evt.clientY); marker.moveTo(pixel); OpenLayers.Event.stop(evt); }); </code></pre> <p>I have console logged out the clientX and clientY clicks and they do register the right x/y coordinates from left and top edges of the browser. But it seems that OL is miscalculating the moveTo at the zoom levels above 15.</p> <p>Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload