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 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示