简体   繁体   中英

Google Maps slow when markers on it

Im writing a small webapp based on the idea of openspot for training proposal.

When I open the map with my desktop pc everything is fine, but when I open it with my HTC Desire and add a marker the map hangs.

You can find a demo here (in german)

http://park-a-lot.de

Just go to "eintragen" and set a marker. Then go hack and click on "parkplatze".

You'll see the issue.

Its ok that the toolbar at the top hides when you move the map, because of a jqtouch bug with Google maps.

Thank you in advance.

This solution may help. I know it works great in the ipod safari browser and Opera on an HTC Android phone.

http://nickjohnson.com/b/google-maps-v3-how-to-quickly-add-many-markers

Having lots of markers on the map does really slow it down on android. One thing you can try is to only show the relevant markers, ie those that are in the bounds of the map. In my case this made the map much less sluggish:

    google.maps.event.addListener(map, 'bounds_changed', function() {
      var bounds = map.getBounds();
      for (id in stations) {
        var marker = stations[id].marker;
        var isVisible = marker.getVisible();
        var shouldBeVisible = bounds.contains(stations[id].latLng);
        if (isVisible != shouldBeVisible) {
          marker.setVisible(shouldBeVisible);
        }
      }
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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