Dear List,<br><br>I am trying to create markers as point features of a vector layer. I do this by using the following code:<br><br> var markerStyle = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default','select']);<br>
markerStyle.graphicWidth = 21;<br> markerStyle.graphicHeight = 25;<br> markerStyle.graphicOpacity = 1;<br> markerStyle.externalGraphic = ""; // I put the url of the image here<br>
markerStyle.graphicTitle = displayName; // displayName is a string previously defined<br> var markerCoordPoint = new OpenLayers.Geometry.Point(markerCoords.lon,markerCoords.lat); // markerCoords is a LonLat object<br>
var newMarker = new OpenLayers.Feature.Vector(markerCoordPoint,null,markerStyle); <br><br>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, <br>
however the center of the image is put to the Lon/Lat coordinates I specify for the newMarker variable. <br>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.<br>
I tried to add the following to the markerStyle object:<br><br> markerStyle.graphicXOffset = -(markerStyle.graphicWidth/2);<br> markerStyle.graphicYOffset = -markerStyle.graphicHeight;<br>
<br>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, <br>especially in low zoom levels. Is there some way to 'anchor' the externalGraphic the way I want to?<br>
Thank you<br><br><br>