[OpenLayers-Users] Markers change position after zooming

Albin Blaschka albin.blaschka at standortsanalyse.net
Sat May 2 09:04:08 EDT 2009



Dear List,

I am putting together a small utility for a group of botanists on the 
basis of Openlayers (Trying 2.8 RC1, hosted version).

Two simple usecases:

* The user clicks on the map to set a marker
* The user gives some coordinates via two input boxes - on this
   coordinate a marker should be set.

So far, so good - or not quite:
The markers are set accordingly, but after changing the zoom level the 
markers are not on the original place anymore.

I found Ticket #1766, which seems at least related, but it is marked 
closed...

I am following the examples on the Openlayers Website, just with small 
modifications for my region...

I am setting the markers in this way:

// Triggered after click...

var proj = new OpenLayers.Projection("EPSG:4326");
var lonlat = map.getLonLatFromViewPortPx(e.xy,proj);
addPoint(lonlat);

function addPoint(point) {
     var url = 'http://boston.openguides.org/markers/YELLOW.png';
     var sz = new OpenLayers.Size(10, 17);
     var calculateOffset = function(size) {
     	return new OpenLayers.Pixel(-(size.w/2), -size.h);
     };
     var icon = new OpenLayers.Icon(url, sz, null, calculateOffset);
     var marker = new OpenLayers.Marker(point, icon);
     markers.addMarker(marker);
}

Everything is online: http://maps.sabotag.at (sorry, everything is in 
german...and still in heavy development...)

Any hints appreciated...

Thanks in advance,
Albin

-- 
---------------------------------------------------------------------
| Albin Blaschka, Mag. rer.nat - Salzburg, Austria
| http://www.albinblaschka.info   http://www.thinkanimal.info
| It's hard to live in the mountains, hard, but not hopeless!
---------------------------------------------------------------------



More information about the Users mailing list