[OpenLayers-Users] clickTolerance on selectFeature?
Phil Scadden
p.scadden at gns.cri.nz
Tue Aug 10 18:07:01 EDT 2010
> I'm mainly dealing with polylines, but if that is the only way, then
> so be it. How can I perform buffer calculations?
>
Buffering every line in your display to see if selected is very
intensive. If you are struggling with accurate selection of lines, can I
suggest an alternative approach? If you use a highlight only hoverselect
control as well as a select control, then you can move mouse till target
is highlighted, then click to select.
Code like:
HoverSelectControl = new
OpenLayers.Control.SelectFeature(myLayers,{hover:true, highlightOnly:
true, renderIntent: "temporary" });
SelectControl = new
OpenLayers.Control.SelectFeature(myLayers,{clickout: true});
SelectControl.events.on({
"featurehighlighted": onFeatureSelect,
"featureunhighlighted": onFeatureUnselect
});
map.addControl(HoverSelectControl);
map.addControl(SelectControl);
HoverSelectControl.activate();
SelectControl.activate();
The order you add controls is important - hover first. I find that this
feels quite natural.
If the layers cans handle wfs, you might be better to create a
wfsprotocol object and do a spatial intersects
query, passing a rectangle around the click point and then processing
the return.
--
Phil Scadden, Senior Scientist GNS Science Ltd 764 Cumberland St,
Private Bag 1930, Dunedin, New Zealand Ph +64 3 4799663, fax +64 3 477 5232
Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
More information about the Users
mailing list