1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| function addGetFeatureInfoControl() {
// fabrication de l'id de la barre d'outils dans le layerSwitcher :
// "basic_<LayerSwitcherId>_<LayerId>"
var lsid= "" ;
var lss= this.map.getControlsByClass("Geoportal.Control.LayerSwitcher") ;
lsid= lss[0].id+"_" ;
//this===layer
var blc= this.map.getControlsBy('id', 'basic_'+lsid+this.id)[0];
if (!blc) { return; }
var wic= new OpenLayers.Control.WMSGetFeatureInfo({
url:"http://d-idg.info.ratp:6080/arcgis/services/ouvrages_cc49/MapServer/WMSServer",
layers:[this],//'0','1','2','3','4','5','6','7','8','9','10'
title:"Identifier les « " + this.name + " »",
type:OpenLayers.Control.TYPE_BUTTON,
queryVisible:true,
maxFeatures:1,
eventListeners:{
getfeatureinfo:function(event) {
//this===control
if (event.text) {
this.map.addPopup(new
OpenLayers.Popup.FramedCloud(
"chicken",
this.map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true,
function(){
console.log("close manually");
this.destroy();
}
)
);
}
}
}
});
blc.addControls([wic]);
// by default, it's activated !
wic.activate();
} |
Partager