简体   繁体   English

谷歌地图API 3地图上的所有标记都打开相同的信息窗口

[英]All markers on google maps api 3 map open same infowindow

I'm working on a website, one page features a styled Google map (Google maps api 3) with several markers - each has their own infowindow. 我在一个网站上工作,一页上有一个样式化的Google地图(Google Maps api 3),上面有几个标记-每个标记都有自己的信息窗口。 On the staging site there are currently 40+ markers. 在分期站点上,目前有40多个标记。

My client (chrome 49 on pc) mentioned that every marker is opening the same infowindow on click. 我的客户(在PC上为Chrome 49)提到,每个标记在点击时都打开相同的信息窗口。 I checked on my machine and each marker was revealing it's own infowindow as expected. 我检查了机器,每个标记都按预期显示了自己的信息窗口。 I tested on my android phone and noticed both that the map was incredibly sluggish and that each marker click indeed opened the same infowindow. 我在Android手机上进行了测试,发现地图非常缓慢,而且每个标记单击的确打开了相同的信息窗口。

My current best guess is that this is caused by low CPU devices or that I am not using the best event delegation. 我目前的最佳猜测是这是由CPU设备不足引起的,或者我没有使用最佳事件委托。

Here's the code I am using to init the map and add the markers + info windows - http://pastebin.com/2RxQPWsd 这是我用来初始化地图并添加标记+信息窗口的代码-http://pastebin.com/2RxQPWsd

Is this issue being caused by some code I can improve or is this due to limitations of the Google Maps API on low CPU devices? 此问题是由我可以改进的某些代码引起的,还是由于CPU数量少的Google Maps API的限制所致?

Thanks! 谢谢!

Christopher 克里斯托弗

I am still waiting for my client to confirm this is fixed on their computer but I can confirm that I managed to fix this issue on android and ios (simulator). 我仍在等待客户端确认此问题已在他们的计算机上解决,但我可以确认自己已设法在android和ios(模拟器)上解决此问题。

I owe my solution to this previously posted stack Google Maps API v3: custom markers not clickable on mobile devices 我的解决方案归功于此之前发布的堆栈Google Maps API v3:自定义标记无法在移动设备上点击

My script was using strings for width and height of size properties and x and y of achor properties for the icons. 我的脚本使用的是字符串的大小属性的宽度和高度,以及图标的achor属性的x和y。 The attached stack post mentions similar issues being resolved by changing the string to integers. 随附的堆栈文章中提到了通过将字符串更改为整数来解决的类似问题。 Changing the strings to ints ex. 将字符串更改为int ex。 "30" to 30 appears to have resolved the issue for me! “ 30”到30似乎已经为我解决了该问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM