Skip to content
April 10, 2012 /

OpenLayers – Drag and Select at once

Here is my first snippet of OpenLayers Code. I didn’t find any similar on the Web so i wanna share this with you!
Define a SelectFeature Control and a DragFeature Control. Then override the onStart function of the DragFeature Control and call the clickFeature method of the selectFeature Control within.
Add the DragFeature Control to the MapControls and activate it. Don’t add or activate the selectFeature Control.

Now every time you click and/or drag a feature it becomes selected.

[map and layer declaration goes here]

var selectFeature = new OpenLayers.Control.SelectFeature(layer,{});

var dragFeature = new OpenLayers.Control.DragFeature(layer, {
  onStart: function(feature, pixel){

Additional Posts:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: