[OpenLayers-Users] Selecting markers and vector features

Heidt, Christopher M. CHRISTOPHER.M.HEIDT at saic.com
Thu Oct 2 12:52:11 EDT 2008


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.


-----Original Message-----
From: Eric Lemoine [mailto:eric.c2c at gmail.com] 
Sent: Thursday, October 02, 2008 3:07 AM
To: Heidt, Christopher M.
Cc: users at openlayers.org
Subject: Re: [OpenLayers-Users] Selecting markers and vector features

On Tue, Sep 30, 2008 at 9:51 PM, Heidt, Christopher M.
<CHRISTOPHER.M.HEIDT at saic.com> wrote:
>
> I need to be able to select markers and features without having to 
> make the user select between two different tools.
>
> What's the easiest way to allow a user to transparently interact with 
> features in the markers Layer and the vectors Layer?

Have the markers and features in the same vector layer, and use the select feature control. This may not be ideal if you don't want the markers and features be in the same layer, but this is the only option you have at this point.

Cheers,

--
Eric



More information about the Users mailing list