How to display markers (huge numbers) on a map which has been logically divided into segments?

社会主义新天地 提交于 2019-12-04 21:54:40

To deal with a very large (50K+) data set , I would do all the heavy number crunching server side and send over a new JSON response whenever the map is updated. Something like the HTML page described here

The key section of the code is the ZoomObserver:

var zoomObserver = function (obj, key, newValue, oldValue) {
  zoom = newValue;
  if (zoom < 7)
    { zoom = 7;}
  if (zoom > 16)
    { zoom = 16;}
  // Define the XML filename to read that contains the marker data
  placeMarkersOnMaps('http://api.maps.nokia.com/downloads/java-me/cluster/'+ zoom + '.xml' 
    + '?lat1=' + map.getViewBounds().topLeft.latitude
    + '&lng1='+ map.getViewBounds().topLeft.longitude
    + '&lat2='+ map.getViewBounds().bottomRight.latitude
    + '&lng2='+ map.getViewBounds().bottomRight.longitude);
};

map.addObserver("zoomLevel", zoomObserver );

Where the REST service returns a "well-known" data format which can be used to add markers and clusters to the map.

Now assuming you have two massive data sets you could make two requests to different endpoints, or somehow distinguish which cluster of data belongs to which so that you would just be returning information of the form:

{latitude':51.761,'longitude':14.33128,'value':102091},

i.e. using the DataPoint standard (which means you could use a heat map as well.

Of course, what I'm not showing here is the back-end functionality to cluster in the first place - but this leaves the client (and the API) to do what it does best displaying data, not number crunching.

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