[OpenLayers-Users] externalGraphic anchoring points?

Arnd Wippermann arnd.wippermann at web.de
Tue Jul 27 17:28:50 EDT 2010


I have always thought the anchorpoint is left-top. But your nice example
suggest it's the center of the externalGraphic.

Looking at the code, it seems to be a bit complexer. 

SVG.js, similiar for VML.js
var xOffset = (style.graphicXOffset != undefined) ? style.graphicXOffset :
-(0.5 * width);
var yOffset = (style.graphicYOffset != undefined) ? style.graphicYOffset :
-(0.5 * height);

If you declare the properties graphicXOffset and graphicYOffset in your
style, then these values are taken for drawing. If you omit these
properties, then an offset of half the width or height are taken.

Because I use always the properties graphicXOffset=0 and graphicYOffset=0 in
conjunction with externalGraphic, I have the anchorpoint always at left-top.
 
If you want to use an offset to move the image, then you have to calculate
from left-top and not from the center as your example seems to show.

Arnd


-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von MostlyBaldEagle
Gesendet: Dienstag, 27. Juli 2010 20:03
An: users at openlayers.org
Betreff: Re: [OpenLayers-Users] externalGraphic anchoring points?


It's the center of the image.

Easy to see if you connect two images with a line :-)

Make sure the line feature is added to the layer before the two images(point
features), then the line will usually show up on top.

See example:

http://osgeo-org.1803224.n2.nabble.com/file/n5343347/test_2_8.htm
test_2_8.htm
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/externalGraphic-anchoring-points-tp53
42684p5343347.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list