4

I am trying to emit a map click from the MapView object using its emit method. I have successfully done this in the 3x API from the Map object. This same method, however, is not working for me in the 4x API. The Map object no longer has an emit method, and I can't get the MapView object's emit method to work. It is not generating any errors for me to debug. This is the code I am currently using:

var mapPt = evt.result.feature.geometry;
app.mapView.emit("click", {mapPoint:mapPt});

Based on the API documentation, it is not clear to me why this isn't working. I have also tried specifying the screenpoint X and Y. This had no effect. I tried simulating a mouse click using vanilla javascript and with jquery, but neither method interacts with the app or MapView objects. The click event triggered outside of the API appears to be superficial to the DOM.

I am trying to emit a click event after the search widget returns a result, as I want the popup behavior/content to be identical to what is created using a map click. I am trying to avoid having to re-code all the popup templates for the various layers specifically for the search widget when I have already specified the popup templates when I defined the feature layers.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Apr 17, 2019 at 22:00

1 Answer 1

-1

In order to emit a click event - a new esri point should be created:
// Change the SpatialReference map.emit('click', {mapPoint: new esri.geometry.Point(mapPt.longitude, mapPt.latitude, esri.SpatialReference({wkid:102100}))});

The answer is based on/copied from this GeoNet thread.

answered Jun 20, 2019 at 20:17
1
  • 3
    The GeoNet example referenced appears to be using the Version 3.x API while the OP is asking about Version 4.x. Can confirm (at least on my end) this sort of direct emit function is not working in version 4.11. Another V4.x thing to consider here is that click events are handled on the MapView class rather than Map (as it was in V3.x). According to the docs, emit is recommended to be used in subclasses only developers.arcgis.com/javascript/latest/api-reference/… Commented Aug 16, 2019 at 20:46

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.