Hi Arnd, I am trying this myself, but fail to succeed.
1. How do I trigger this on every time Zoom levels changes ? 2. Do textSymbolizers move to or is it just the graphic ? I have a simple graphic, which I am labeling with ascending numbers, will both of them move ? thanks in advanced ! Ricardo On Fri, Aug 20, 2010 at 9:13 AM, Arnd Wippermann <[email protected]>wrote: > Hi, > > you have to calculate your offset for every zoomlevel. I do it by use of a > styleMap with context. The code below should give you an idea, how to get it > work. > > function layerContext() > { > theXOffset = 10; > theYOffset = 10; > theResolution = map.getResolution(); > > var context = { > getXO : function(){ > return theXOffset * theResolution / map.getResolution(); > }, > getYO : function(){ > return theYOffset * theResolution / map.getResolution(); > } > }; > var template = { > ... > graphicXOffset : "${getXO}", > graphicYOffset : "${getYO}", > ... > pointRadius : 0 > }; > yourLayer.styleMap = new OpenLayers.StyleMap(new > OpenLayers.Style(template, {context:context}) ); > } > I use this approach to display georeferenced images as externalGraphic. > > http://gis.ibbeck.de/ginfo/apps/OLExamples/OL27/examples/ExternalGraphicOverlay/ExternalGraphicOverlay.asp > > Arnd > > ------------------------------ > *Von:* [email protected] [mailto:[email protected]] > *Im Auftrag von *ilias kanellos > *Gesendet:* Donnerstag, 19. August 2010 11:03 > *An:* [email protected] > *Betreff:* [OpenLayers-Users] External Graphic of features positioning > > Dear List, > > I am trying to create markers as point features of a vector layer. I do > this by using the following code: > > var markerStyle = OpenLayers.Util.extend({}, > OpenLayers.Feature.Vector.style['default','select']); > markerStyle.graphicWidth = 21; > markerStyle.graphicHeight = 25; > markerStyle.graphicOpacity = 1; > markerStyle.externalGraphic = ""; // I put the > url of the image here > markerStyle.graphicTitle = displayName; // > displayName is a string previously defined > var markerCoordPoint = new > OpenLayers.Geometry.Point(markerCoords.lon,markerCoords.lat); // > markerCoords is a LonLat object > var newMarker = new > OpenLayers.Feature.Vector(markerCoordPoint,null,markerStyle); > > When I add the above feature to a vector layer and put in on my map it > displays the image I want in the correct coordinates, > however the center of the image is put to the Lon/Lat coordinates I specify > for the newMarker variable. > What I would like to do is to set a specific point (such as the center of > the bottom, or the bottom left corner) of the image to be put on the > determined coordinates. > I tried to add the following to the markerStyle object: > > markerStyle.graphicXOffset = > -(markerStyle.graphicWidth/2); > markerStyle.graphicYOffset = > -markerStyle.graphicHeight; > > However if I understood this correctly, the above offset concerns pixels, > and the result is that the marker image gets placed in a completely wrong > position, > especially in low zoom levels. Is there some way to 'anchor' the > externalGraphic the way I want to? > Thank you > > > > _______________________________________________ > Users mailing list > [email protected] > http://openlayers.org/mailman/listinfo/users > >
_______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
