0

I am showing some markers using latitude and longitude, but there is a navigation drawer view, where I can click on the location.

So if I click on any particular location from the drawer, how can I trigger the click event on the associated marker?

Is there any way I can trigger the location item click from drawer to trigger marker click?

 let marker = new Graphic({
  geometry: {
    longitude: item.longitude,
    latitude: item.latitude,
    type: 'point',
    spatialReference: { wkid: 3857 },
  },
  symbol: this._Constants.MARKER_FLAT,

  popupTemplate: {
    title: item.name,
    content: function () {
      var div = document.createElement('div');
      div.innerHTML = `<p>Testing</p>`;
      return div;
    },
  },
});

marker.setAttribute('id', String(item.id));
marker.setAttribute('name', String(item.name));

this.mapView.graphics.add(marker);
this.marker = marker;

This Is how I plot the markers

I have tried this approach, but the emit event is returning false.

 if (
  // this.mapView.emit('click', {  // tried this as well
  this.mapView.map.emit('click', {
    mapPoint: this.marker,
  })
 ) {
  console.log('Triggered');
 } else {
  console.log('NOT Triggered');
 }
Sanoop Surendran
  • 3,484
  • 4
  • 28
  • 49
  • I imagine that you can add a (click) to all the map and check the e.target, if is a mark, you can use regExp to get the "data of the mark" and make something. It's looks like this [SO](https://stackoverflow.com/questions/71220617/angular-12-d3-tree-displaying-a-routerlink) - The question is about D3Tree, but perhafs you can use a similar "tecnica" – Eliseo Jun 10 '22 at 08:34
  • @Eliseo Yea, I see your point. Surely will try and reply back the progress. Thanks – Sanoop Surendran Jun 10 '22 at 09:55

1 Answers1

0

If the purpose of your "trigger a click event" is specifically to make the popup display for your "this.marker", then you can use view.popup.open to trigger/open the popup.

The view.popup.open can take several inputs, including a location to look for features or to display a popup without a specific feature. There are several code snippets at https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#open

Based on your code:

view.popup.open({
  location: this.marker.geometry, // location of the click on the view
  fetchFeatures: true // display the content for the selected feature if a popupTemplate is defined.
});

See also https://gis.stackexchange.com/questions/433141/trigger-click-event-on-existing-map-marker/433501 :)

Bjorn Svensson
  • 815
  • 8
  • 21