触发单击标记上的事件以编程方式-ArcGIS

发布于 2025-02-06 04:48:15 字数 984 浏览 3 评论 0原文

我正在使用纬度和经度显示一些标记,但是有一个导航抽屉视图,可以单击该位置。

因此,如果我从抽屉中单击任何特定位置,如何在关联标记上触发单击事件?

有什么方法可以触发位置项从抽屉中单击以触发标记单击?

 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;

这就是我绘制

尝试使用这种方法的标记的方式,但是发射事件正在返回错误。

 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');
 }

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');
 }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只为一人 2025-02-13 04:48:15

如果您的“触发点击事件”的目的是为“ this.marker”的弹出显示,则可以使用view.popup.open触发/打开弹出窗口。

view.popup.open可以采用多个输入,包括查找功能的位置或在没有特定功能的情况下显示弹出窗口。 https:// developers.arcgis.com/javascript/latest/api-reference/esri-widgets-popup.html#open

基于您的代码:

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.
});

另请参阅 https://gis.stackexchange.com/questions/questions/433141/trigger-cligger-click-click-click-click-event-event-on-ex-map-map-map-marker/433501 < /a> :)

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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文