色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

google地圖的路線實現(xiàn)代碼

復(fù)制代碼 代碼如下:
<script language="Javascript" type="text/Javascript">
//add by ahuinan 2009-8-17
//initialize(23.165613663312594,113.35968017578125)
var map;
var gdir;
var marker2;
var hasMarker = false;
var hotelLatLng = new GLatLng(<%=initxy %>);//初始化酒店的坐標(biāo)
var polyline;
var points = [];
points[1] = hotelLatLng;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("divMap"), { googleBarOptions: { showOnLoad: true} });
gdir = new GDirections(map);
map.setCenter(hotelLatLng, 9);
map.addControl(new GOverviewMapControl());
map.addControl(new GLargeMapControl());

//加入搜索框
map.enableGoogleBar();

map.enableScrollWheelZoom();

//創(chuàng)建酒店的標(biāo)注,不可拖動
var hotelMarker = new GMarker(new GLatLng(<%=initxy %>));
map.addOverlay(hotelMarker);

//鼠標(biāo)左鍵可以建立一個標(biāo)記,
GEvent.addListener(map,"click",function(overlay,latlng,overlaylatlng){
if(latlng == null || hasMarker == true){
return;
}
var greenIcon = new GIcon(G_DEFAULT_ICON);
greenIcon.image = "../googlemap/green-dot.png";
greenIcon.iconSize = new GSize(32,32);
greenIcon.iconAnchor = new GPoint(16,32);
greenIcon.shadowSize=new GSize(56,33);
marker2 = new GMarker(latlng,{draggable: true,icon:greenIcon});
map.addOverlay(marker2);

GEvent.addListener(marker2,"dragend",function(){
points[0] = marker2.getLatLng();
gdir.loadFromWaypoints(points,{"preserveViewport":true});



})
GEvent.addListener(gdir, "addoverlay", function(){
for (var i=0; i<=gdir.getNumRoutes(); i++){
var originalMarker = gdir.getMarker(i);
map.removeOverlay(originalMarker);
}
polyline = gdir.getPolyline();


polyline.setStrokeStyle({color:"red",weight:2,opacity:1});
// map.addOverlay(polyline);

});
hasMarker = true;
points[0] = latlng;
gdir.loadFromWaypoints(points,{"preserveViewport":true});

})
}
}
//按下添加按鈕
function add(){
if(points.length == 1){
alert("沒有線路,終止操作");
}else{
window.opener.document.getElementById("txtHI_MapMarkDesc").value = window.opener.document.getElementById("txtHI_MapMarkDesc").value+"/n"+document.getElementById("txtName").value+"||||"+document.getElementById("txtType").value+"||||"+points[0]+"/n";
window.close();
}
}
window.onload = function() {
initialize()
}
</script>

JavaScript技術(shù)google地圖的路線實現(xiàn)代碼,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 南靖县| 通城县| 仁寿县| 邢台市| 宿松县| 连州市| 阳城县| 扎兰屯市| 乌苏市| 潞城市| 泽普县| 涞水县| 襄樊市| 潞城市| 永寿县| 元氏县| 辰溪县| 白银市| 郴州市| 潮州市| 类乌齐县| 邢台市| 乡城县| 右玉县| 锦州市| 巴里| 肥西县| 嫩江县| 临江市| 涟源市| 游戏| 皮山县| 江津市| 江永县| 二连浩特市| 峨山| 灵璧县| 嘉禾县| 宁河县| 城市| 屯留县|