-1
我在我的網站中使用gmaps
,並且想要在google maps
中放置多於一百個標記以顯示用戶位置。當通過json
數據訪問所有這些標記時,它可以分解連接或減慢我的網站速度。由於這些標記數據存儲在array
文件中。GMaps - 放置超過100個標記
var values = [
{"lat" : "51.508742", "ln" : "-0.120850", "name" : "a new user" },
{"lat" : "51.508742", "ln" : "-0.320850" , "name" : "my corporation"},
{"lat" : "51.508742", "ln" : "-0.420850" , "name" : "my corporation"},
{"lat" : "51.508742", "ln" : "-0.520850" , "name" : "my corporation"},
{"lat" : "51.508742", "ln" : "-0.620850" , "name" : "my corporation"},
{"lat" : "51.508742", "ln" : "-0.720850" , "name" : "my corporation"},
{"lat" : "51.508742", "ln" : "-0.820850" , "name" : "my corporation"},
{"lat" : "51.508742", "ln" : "-0.920850" , "name" : "my corporation"},
{"lat" : "51.508742", "ln" : "-1.320850" , "name" : "my corporation"},
{"lat" : "51.508742", "ln" : "-2.320850" , "name" : "my corporation"},
{"lat" : "51.508742", "ln" : "-3.320850" , "name" : "my corporation"}
]
而且我訪問他們爲:
var myCenter=new google.maps.LatLng(values[0]["lat"],values[0]['ln']);
function initialize()
{
var marker;
function callMe(v,i){
marker=new google.maps.Marker({
position: new google.maps.LatLng(values[i]["lat"],values[i]['ln']) ,
});
marker.setMap(map);
}
var mapProp = {
center:myCenter,
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
values.forEach(callMe);
}
google.maps.event.addDomListener(window, 'load', initialize);
我可以顯示所有這些標記的同時或者我應該限制他們的表現?
此回答對我很有幫助。謝謝 –