Google Maps with too many marks

回眸只為那壹抹淺笑 提交于 2019-12-05 09:16:42

问题


I am using the Android's WebView component to display Google Maps with POIs. For displaying the POI I am using the JavaScript API class google.maps.Marker.

The problem is that when all 350 POIs are shown on the map they makes the WebView slow and almost unusable...

How to optimize it???

Is there any API that e.g. puts together the map zoom level with the number of marks displayed? For example if the the zoom level is 0, e.g. 10 POIs is shown and when the zoom level is 10, all which can fit the view port are displayed...

Thanks for help Regards, Petr


回答1:


Too many markers on the map is a well known problem. There are several solutions to this. Nice overview of possible solutions can be found here.

If I sum it up shortly, then the solutions are:

  1. Clustering: It groups markers such that there are not too many markers visible on the map at one time. If you zoom in, the clusters splits into smaller clusters and/or single markers. You can either create your own marker clusterer or use some library that provides the required functionality. Great solution can be found in Google Maps utility library.
  2. Marker manager: Marker manager allows you to specify what markers are visible at different zoom levels. Again you can create you own implementation or use a library. Google Maps utility library provides good MarkerManager.
  3. Viewport managment: The idea is to show only the markers that are necessary to be shown (those that are located in the current viewport). While it doesn't solve the problems completely, it's a good improvement of the previous techniques.
  4. Fusion Tables: When you use Fusion tables, the markers are rendered on Google servers in a special layer.


来源:https://stackoverflow.com/questions/8204193/google-maps-with-too-many-marks

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