So i'm just kicking off my first WAB widget and immediately running into an issue trying to set map click handlers when the widget is opened. Looking through the esri coordinate widget i found this...
this.own(on(this.map, "click", lang.hitch(this, this.onMapClick)));
But I just can't get it to register the event, here's my full code...
define([
'dojo/_base/declare',
'jimu/BaseWidget',
'esri/geometry/Point',
'esri/SpatialReference'
],
function(declare, BaseWidget) {
//To create a widget, you need to derive from BaseWidget.
return declare([BaseWidget], {
// Custom widget code goes here
baseClass: 'jimu-widget-customwidget',
startup: function() {
this.inherited(arguments);
//this.mapIdNode.innerHTML = 'map id:' + String(this.map.getScale());
},
onOpen: function(){
this.own(on(this.map, "click", lang.hitch(this, this.onMapClick)));
},
onMapClick: function(event) {
window.alert('map click');
this.mapIdNode.innerHTML = 'map id:' + String(event.mapPoint.x);
}
});
});
I'm very confused why this isn't working.
Also does anyone know where i can find better documentation specific to the WAB? i also found this in the measurement widget and trying to work out the differences is giving me a headache, there seems to be a lot of methods/functions not found in the JSAPI and it would be nice to know what they are.
if (this.map && this.map.webMapResponse) {
var handler = this.map.webMapResponse.clickEventHandle;
if (handler) {
handler.remove();
this.map.webMapResponse.clickEventHandle = null;
}
}
Thanks all!
Richard