1

I am using an ArcGIS App which was created in ArcGIS Web App Builder 2.2. I am trying to connect to a map click event and/or a widget click event to run a custom made function. I have made simple apps and have been able to connect to click events in the past. With the apps created in Web App Builder the .js files are spread out all over the place and I am not that advanced in JavaScript to figure this out. I guess I am having trouble getting a handle on the map object which contains the lat, long, etc. of the click event. How would I find the map object to tie these events. Before I had just had all my .js code in one file and tied a click event like this simple example:

map = new Map("map",{
    basemap:"Street",
    center: center,
    zoom: 3
    });

map.on("click",mapClickEvent);

function mapClickEvent(evt){
    console.log(evt);
}

1 Answer 1

2

we wrote a tutorial and put it on github to discuss the anatomy of simple widgets and how they obtain a reference to the map. please check it out.

function(declare, BaseWidget, SimpleMarkerSymbol, Graphic) {
  var clazz = declare([BaseWidget], {
  templateString: '<div><input type="button" value="click me to add a graphic!" data-dojo-attach-event="click:_addGraphic"></div>',

  // Add a point at center of extent
  _addGraphic: function(){
  var centerPoint = this.map.extent.getCenter();
  // ...
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.