[OpenLayers-Dev] Marker Vector Trouble

Ryan Hofschneider ryan.hofschneider at ngc.com
Mon Sep 10 15:42:47 EDT 2007


On Sep 10, 2007, at 11:26 AM, Graf, David wrote:
> I'm having difficulty getting the features from the vector layer to  
> match up with the markers in the marker layer. Meaning that if I  
> set up a marker with a LonLat and give the same LonLat to the  
> feature from the vector layer they don't end up in the same spot on  
> the map.
When using markers with the WFS layer class I discovered that the  
default icon that is created in Marker.js (line 195 in the trunk  
copy) offsets it by a certain amount. Maybe you've come across the  
same thing.

If you want it exactly centered over the position, I believe you want  
something like OpenLayers.Pixel(-(size.w/2), -(size.h/2)) when you  
define your Icon. For my particular case of WFS markers, I sub- 
classed the OpenLayers.Feature.WFS class and provided a new  
implementation of createMarker() which provided an icon with my  
desired offsets.

Although you aren't using the WFS class, you could do something similar.

Cheers,
Ryan











More information about the Dev mailing list