开发者

Google Map JS API v3 Marker not clickable

开发者 https://www.devze.com 2023-03-15 07:08 出处:网络
i am having a bit of a fight with the Google Map API v3 and the iPhone. I am binding a click event on the markers, but when the use开发者_如何学编程r-agent is iPhone, nothing is clickable (works fine

i am having a bit of a fight with the Google Map API v3 and the iPhone. I am binding a click event on the markers, but when the use开发者_如何学编程r-agent is iPhone, nothing is clickable (works fine on Android, Desktop browsers).

google.maps.event.addListener(marker, 'click', (function(marker, i) {
                    return function() {
                                        alert("click")
                    }
                })(marker, i));

It seems Google is preventing the click event to happen when the user agent is iPhone. I've been fighting with this for 3days now, and i am really getting upset as there is no error and almost no documentation for this on the internet.


I imagine it would work everywhere if you simplified to this:

google.maps.event.addListener(marker, 'click', function(marker, i) {
                                    alert("click")
            });


The issue was actually quite simple, but not clear to debug, Google Map js API as a limit of 8 Markers you can place on a map, going above the limit apparently causes issues with the map itself.

Adding a hardcoded limit of 8 markers solved the issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消