3

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.

0

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.

  • 1
    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/… – Chaz Aug 16 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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