dsa2c2255888 2011-09-08 14:49
浏览 11
已采纳

显示包含超过7000个地点标记的Google地图的最佳方式是什么?

I am using the googlemaps V3 codeigniter class with codeigniter (obviously) to loop through location from my database and output a map with all the location plotted on it. The trouble is I have over 7000 placemarkers, so the generated javascript is massive and page load time is very slow. Is there a better way of outputting this map to reduce overheads?

I have clustered the markers but when the map is loading sometimes the browser will freeze while its contacting google

Thanks

  • 写回答

2条回答 默认 最新

  • dte8665 2011-09-08 15:39
    关注

    I think the problem is that if you have that amount of markers in memory browsers get really slow.

    I had a similar problem some time ago and what we finally did was to load only the visible markers and load / unload them when the user pans or zooms via AJAX. it is quite easy to implement using the events moveend and zoomend.

     // Listeners
    
     GEvent.addListener(map2, "moveend", function() {            
             map2.clearOverlays();
             // Load markers for the current bounds and current zoom level 
             loadMarkers(map2,map2.getBounds(),map2.getBoundsZoomLevel(map2.getBounds()));
     });
    
     GEvent.addListener(map2, "zoomend", function() {
            map2.clearOverlays();
            // Load markers for the current bounds and current zoom level 
           loadMarkers(map2,map2.getBounds(),map2.getBoundsZoomLevel(map2.getBounds()));
     });
    

    And for the lower zoom levels when a lot of marker have to be shown , we clustered them on the server side and only load the marker that represente each cluster.

    Another way to achieve this that is a bit more complicated is to render the makers in a custom overlay tiles in the server side. But I think you will need a map server to do it so. you can read more about it in the google maps documentation

    http://code.google.com/intl/en/apis/maps/documentation/javascript/examples/overlay-simple.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥15 vba使用jmail发送邮件正文里面怎么加图片
  • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。