[英]how to trigger click from external link on google.map.data.feature not on marker
I want to trigger click event from external link on google.map.data.feature. 我想从google.map.data.feature上的外部链接触发点击事件。
My code looks something like this 我的代码看起来像这样
function init(query){
map = new google.maps.Map(document.getElementsByClassName('map')[0], {
zoom: 12,
center: {
lat: 17.3850,
lng: 78.4867
}
});
map.data.setStyle(feature=>{
return {url:`image`, scaledSize: new google.maps.Size(32,32)}
})
map.data.addListener('click', clickEventOnMapData);
map.data.loadGeoJson(`some url`);
}
I have clickEventOnMapData written which is opening up a window on click of markers. 我写了clickEventOnMapData,它在单击标记时打开了一个窗口。
Now I have an external button on click of which I want to trigger the same clickEventOnMap for the particular data.feature. 现在,我有一个外部按钮,单击该按钮我想为特定的data.feature触发相同的clickEventOnMap。
Code for that is 的代码是
function openWindow(lsqid){
map.data.forEach((feature)=>{
if(feature.getProperty('lsqid') === lsqid){
google.maps.event.trigger(feature, 'click');
}
});
}
Now from above I get the feature on which I want to trigger click event. 现在,从上面我得到了要触发点击事件的功能。 But I am unable to trigger the click event on the particular feature.
但是我无法在特定功能上触发click事件。 Additionally any error is also not displayed on console.
此外,任何错误也不会显示在控制台上。
I apprantly did it via 我当然是通过
function openWindow(lsqid){
map.data.forEach((feature)=>{
if(feature.getProperty('lsqid') === lsqid){
clickEventOnMapData({feature});
}
});
}
and it worked :) 它起作用了:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.