[GIS] Emitting map click using ArcGIS API for JavaScript

arcgis-javascript-apiarcgis-javascript-api-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.

Best Answer

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.

Related Question