Hi all,
I'm trying to set a different behavior of the Popup Panel Widget on map click for each layer.
For a particular layer, I need to retrieve data from a webservice passing a field value as parameter.
Is it right what I'm trying to do or you think I have to move this code somewhere else?
at the moment the line 10 gave me an error:
TypeError: this.own is not a function
startup: function () {
this.inherited(arguments);
var map = this.map;
LayerInfos.getInstance(map, map.itemInfo).then(lang.hitch(function(operLayerInfos) {
operLayerInfos.getLayerInfoArray().forEach(function(layerInfo) {
if (layerInfo.title == 'Map') {
var layerId = layerInfo.id;
console.log('layer ID = ', layerId);
var layer = map.getLayer(layerId);
this.own(on(layer, "click", lang.hitch(this, this.onMapClick)));
}
}
);
}
));
this.displayPopupContent(this.popup.getSelectedFeature());
},
onMapClick: function(event) {
//I want to disable the normal behavior of the click (retrieve data and populate the Popup Panel widget with my customized content)
var queryTask = new QueryTask('*Service URL*');
var query = new Query();
query.returnGeometry = true;
query.outFields = ['*'];
query.geometry = event.mapPoint;
queryTask.execute(query, lang.hitch(this, this.showResults));
},
showResults: function(results) {
var resultItems = [];
var resultCount = results.features.length;
for (var i = 0; i < resultCount; i++) {
var featureAttributes = results.features.attributes;
var URL = "theWebServiceUrl" + featureAttributes.NAME;
//and I want to pass this URL to call it with through esri/request and retrieve data and then populate the PopUp Panel
}
}
Thanks,
Naty