Domanda

Consider this example on GWT-OpenLayers showcase. The example implements the navigate and box selection features separately. How can I implement the navigate and box selection feature together? i.e. I make a selection only when I press 'Shift Key' or 'Ctrl Key', and navigate rest of the time.

È stato utile?

Soluzione

I ended up doing the following which worked for me.

Create a map with no control using:

defaultMapOptions.setControls(new JObjectArray(new JSObject[0]));

Then add custom controls to the map. (Here I'm adding just one)

map.addControl(new PanZoomBar());

The PanZoomBar can help in the panning as well as zooming. This fixes the navigation. As for the box selection,

SelectFeatureOptions selectBoxFeatureOptions = new SelectFeatureOptions();
selectBoxFeatureOptions.setBox(true);
SelectFeature boxSelectFeature = new SelectFeature(vectorLayer,selectBoxFeatureOptions);
boxSelectFeature.setClickOut(false);
boxSelectFeature.setToggle(false);
boxSelectFeature.setMultiple(false);
boxSelectFeature.setToggleKey("ctrlKey");
boxSelectFeature.setMultipleKey("shiftKey");
map.addControl(boxSelectFeature);

Additional Reference

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top