[OpenLayers-Users] Selecting markers and vector features

Eric Lemoine eric.c2c at gmail.com
Sat Oct 4 10:46:44 EDT 2008


On Thu, Oct 2, 2008 at 6:52 PM, Heidt, Christopher M.
<CHRISTOPHER.M.HEIDT at saic.com> wrote:
> Excuse my naiveté, but how do I add markers to a vector layer?
> I've been unable to find an example of this.
>
> Currently I'm:
>
> var feature = new OpenLayers.Feature(_markerLayer, lonlat, {});
> Feature.icon = icon;
> var marker = feature.createMarker();
> Marker.events.register("mousedown",feature,markerClick);
> _markerLayer.addMarker(marker);
>
>
> And for my vector features I'm:
>
> var wktFormat = new OpenLayers.Format.WKT();
> var feature = wktFormat.read(featureGeom);
> feature.id = featureId;
> _vectorLayer.addFeatures(feature);
>
>
> I tried just changing _markerLayer to _vectorLayer but then feature.createMarker seemed to fail.

Use the externalGraphic style property. See the vector-features.html example.

--
Eric


More information about the Users mailing list