如题,我获得了数据库中的经纬度的数组,如何通过循环向谷歌地图中加载图钉?
var jingdu = new Array(); var weidu = new Array(); var dizhi=new Array(); var wenti=new Array(); var dianhua=new Array(); var shijian=new Array(); <% for (int i = 0; i < k1; i++) {%> jingdu.push("<%=RepairLn[i] %>"); weidu.push("<%= RepairLa[i]%>"); dizhi.push("<%= RepairAddress[i] %>"); wenti.push("<%= RepairReason[i] %>"); dianhua.push("<%= RepairTel[i] %>"); shijian.push("<%= RepairDateTime[i] %>"); <% }%>
请尽量给出解决方法的代码,如果可能的话,最好每个marker有相对应信息的悬浮框,谢谢
var
ltlng = [];
ltlng.push(
new
google.maps.LatLng(40.756, -73.986));
ltlng.push(
new
google.maps.LatLng(37.775, -122.419));
ltlng.push(
new
google.maps.LatLng(47.620, -122.347));
ltlng.push(
new
google.maps.LatLng(-22.933, -43.184));
for
(
var
i = 0; i <= ltlng.length; i++) {
marker =
new
google.maps.Marker({
map: map,
position: ltlng[i]
});
(
function
(i, marker) {
google.maps.event.addListener(marker,
'click'
,
function
() {
if
(!infowindow) {
infowindow =
new
google.maps.InfoWindow();
}
infowindow.setContent(
"Message"
+ i);
infowindow.open(map, marker);
});
})(i, marker);
}