GoogleMap Markers are Not Clickable on the Mobile Devices

丶灬走出姿态 提交于 2019-12-02 01:42:13

The problem is because you're doing a loop, you need to use a closure, otherwise all markers will just get the content you want to associate with the last marker. Your first bit of code is doing this correctly. Suggest you change to do the same again:

var infowindow = new google.maps.InfoWindow({content: locations[i][0]});
google.maps.event.addListener( marker, 'click', function(marker, i) {
  return function() {
    infowindow.setContent(locations[i][0]);
    infowindow.open(map,this);
  }
})(marker, i));

I found the following solution : 1. create marker with option

"optimized: false" : ex => new google.maps.Marker({..., optimized: false, ...});
  1. adding another event listener

google.maps.event.addDomListener(marker, "click", function() {...});

From google forum

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!