触发单击标记上的事件以编程方式-ArcGIS
我正在使用纬度和经度显示一些标记,但是有一个导航抽屉视图,可以单击该位置。
因此,如果我从抽屉中单击任何特定位置,如何在关联标记上触发单击事件?
有什么方法可以触发位置项从抽屉中单击以触发标记单击?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的“触发点击事件”的目的是为“ this.marker”的弹出显示,则可以使用view.popup.open触发/打开弹出窗口。
view.popup.open可以采用多个输入,包括查找功能的位置或在没有特定功能的情况下显示弹出窗口。 https:// developers.arcgis.com/javascript/latest/api-reference/esri-widgets-popup.html#open
基于您的代码:
另请参阅 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:
See also https://gis.stackexchange.com/questions/433141/trigger-click-event-on-existing-map-marker/433501 :)