Alexandre,<br><br>thanks again for your help.<br><br>The
event is not triggered with the code you posted so I changed a few things
around, though it's probably not the best way to do this, and it seems
to be triggered:<div class="im"><br><br>
var oDrawPoint = new OpenLayers.Control.DrawFeature(vectors, OpenLayers.Handler.Point);<br></div> vectors.events.on({'<div id=":1g7" class="ii gt">featureadded': onPointFeatureAdded, 'scope': oDrawPoint });<br>
<br>
function onPointFeatureAdded (event) {<br> var feature = event.feature;<br> if (feature.geometry.CLASS_NAME == 'OpenLayers.Geometry.Point') {<br> <br>
var symbolizer = feature.layer.styleMap.createSymbolizer(feature);<div class="im"><br>
feature.style = symbolizer;<br> feature.style.externalGraphic = \"images/markers/marker-gold.png\";<br></div> feature.style.pointRadius = 13;<br> feature.style.fillOpacity = 1;<br>
feature.layer.drawFeature(feature);<br> }<br> }<br><br>Though that if statement there must be surely incorrect but I wasn't able to trigger the event of a point added any other way.<br>
<br>On to figuring out the different images now!<br><br>Thanks,<br><br>Alex<br></div><br><br><div class="gmail_quote">On Fri, Feb 5, 2010 at 3:34 PM, Alexandre Dube <span dir="ltr"><<a href="mailto:adube@mapgears.com">adube@mapgears.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Alex,<br>
<br>
Instead of defining the externalGraphic property directly in your StyleMap (that affects all your features on your layer), you could register a "featureadded" event to your DrawFeature control for points and set the externalGraphic property there. You would need to redraw your feature to affect the new style. This might look like (untested) :<br>
<br>
var oDrawPoint = new OpenLayers.Control.DrawFeature(vectors, OpenLayers.Handler.Point);<br>
oDrawPoint.events.on({"featureadded": onPointFeatureAdded, scope: oDrawPoint});<br>
<br>
var onPointFeatureAdded = function(event) {<br>
var feature = event.feature;<br>
var symbolizer = this.layer.styleMap.createSymbolizer(feature);<br>
feature.style = symbolizer;<br>
feature.style.externalGraphic = "images/markers/marker-gold.png";<br>
feature.style.pointRadius = 10;<br>
this.layer.drawFeature(feature);<br>
};<br>
<br>
The remaining thing to do is to think about how to have different markers for your features.<br>
<br>
Hope this helps,<br>
<br>
Alexandre<br>
<br>
<br>
<br>
Alex G. wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Alexandre,<br>
<br><div><div></div><div class="h5">
thanks again for your valuable help!<br>
<br>
At the moment the best idea would be to have vector points as markers, which would make them both clickable and perfect for what I need to do.<br>
<br>
I have added this info to the vector layer:<br>
<br>
vectors = new OpenLayers.Layer.Vector('Vectors', {<br>
styleMap: new OpenLayers.StyleMap({<br>
externalGraphic: "images/markers/marker-gold.png",<br>
pointRadius: 10<br>
})<br>
});<br>
<br>
And the point appears correctly with the marker icon. But I have run into 2 problems now:<br>
<br>
1) All my polygons and lines appear black or invisible<br>
2) I would like to use more than one image for the markers<br>
<br>
My controls looks like this:<br>
<br>
controls = {<br>
point: new OpenLayers.Control.DrawFeature(vectors,<br>
OpenLayers.Handler.Point),<br>
line: new OpenLayers.Control.DrawFeature(vectors,<br>
OpenLayers.Handler.Path),<br>
polygon: new OpenLayers.Control.DrawFeature(vectors,<br>
OpenLayers.Handler.Polygon),<br>
drag: new OpenLayers.Control.DragFeature(vectors),<br>
select: selectControl<br>
};<br>
<br>
Is there a way to maybe pass the external image specifically to the "point" control?<br>
<br>
I am unsure about the syntax and I wasn't able to find any info around, maybe something like this:<br>
<br>
point: new OpenLayers.Control.DrawFeature(vectors,<br>
OpenLayers.Handler.Point, {style: blah blah}),<br>
<br>
If it's possible, then that solves my 2nd problem as well for different images.<br>
<br>
Thanks in advance!<br>
<br>
Best regards,<br>
<br>
Alex<br>
<br></div></div></blockquote><div><div></div><div class="h5">
<br>
<br>
-- <br>
Alexandre Dubé<br>
Mapgears<br>
<a href="http://www.mapgears.com" target="_blank">www.mapgears.com</a><br>
<br>
</div></div></blockquote></div><br>