[OpenLayers-Users] Order/Priority of Control.GetFeature and Control.WMSGetFeatureInfo on click?
nica
a.walter at gsi.de
Fri Sep 7 07:16:11 PDT 2012
Hello Alexandre,
sorry for taking so long to answer, I was away from work for a while and
just not got around to trying your solution!
The only thing that needed to be changed was that WMSGetFeatureInfo
getInfoForClick needs the click event, not just the event's xy. Now it works
just the way I intended to:
----
///Overriding the selectClick method/
OpenLayers.Control.GetFeature.prototype.selectClick = function(evt) {
*this.lastClick = evt;* ///We need the *click event*, not the *xy
coordinates*/
var bounds = this.pixelToBounds(evt.xy);
this.setModifiers(evt);
this.request(bounds, {single: this.single});
};
///After overriding the method, create the GetFeature control/
getFeatureControl = new OpenLayers.Control.GetFeature ( { ... } );
map.addControl( getFeatureControl );
getFeatureControl.activate();
///Deactivate the (existing) WMSGetFeatureInfo control until we need it/
wmsGFIControl.deactivate();
///On GetFeature clickout, activate the WMSGetFeatureInfo control, let it
run for the last click, and deactivate it again/
getFeatureControl.events.register("clickout", this, function(e) {
wmsGFIControl.activate();
wmsGFIControl.getInfoForClick( getFeatureControl.lastClick ); ///or:
e.object.lastClick/
wmsGFIControl.deactivate();
});
----
Thanks a lot for your help, overriding the selectClick method to remember
the last clicked coordinates never even occurred to me! :)
Anne
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Order-Priority-of-Control-GetFeature-and-Control-WMSGetFeatureInfo-on-click-tp4997282p5000455.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list