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);
}
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 16, 2016 at 20:45

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();
 // ...
}
answered Dec 16, 2016 at 23:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.