2016-02-16 75 views
0

我怎樣才能更正所連接的圖像中的標記(Alphabates),因爲這標誌給出不正確的指針Alphabates名請參閱圖像,我怎樣才能糾正谷歌地圖上的標記

enter image description here

我有這個HTML:

<!DOCTYPE html><html><head><meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Google Maps Directions Waypoints</title> <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> </script> <script type="text/javascript"> var directionDisplay; var directionsService = new google.maps.DirectionsService(); var map;  function initialize() { directionsDisplay = new google.maps.DirectionsRenderer({ }); var myOptions = { zoom: 10, mapTypeId: google.maps.MapTypeId.ROADMAP, } ; map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); directionsDisplay.setMap(map); calcRoute(); } function calcRoute() { var waypts = []; 
    stop = new google.maps.LatLng(51.126232,0.265945) ; 
    waypts.push({location:stop, stopover:true}); 

    stop = new google.maps.LatLng(51.593165,-0.028696) ; 
    waypts.push({location:stop, stopover:true}); 
    stop = new google.maps.LatLng(51.488874,-0.287175) ; 
    waypts.push({location:stop, stopover:true}); 
    stop = new google.maps.LatLng(51.440487,-0.155701) ; 
    waypts.push({location:stop, stopover:true}); 

    start = new google.maps.LatLng(51.126232,0.265945); 
    end = new google.maps.LatLng(51.593165,-0.028696); 


    var request = { origin: start, destination: end, 
    waypoints: waypts, optimizeWaypoints: true, 
    travelMode: google.maps.DirectionsTravelMode.WALKING }; 
    directionsService.route(request, function(response, status) 
    { if (status == google.maps.DirectionsStatus.OK) 
    { directionsDisplay.setDirections(response); 
    var route = response.routes[0]; }  }); } 
    </script> 
    </head> 
    <body onLoad="initialize()"> <div id="map_canvas" style="width:70%;height:80%;"></div> </body></html> 
+0

你期望標記是哪裏?在起始位置有三個(起點,終點和第一個航點是相同的)。 – geocodezip

回答

0

看來,你的出發點和第一個航路點是完全一樣的點,所以它發生在B在A的頂部顯示

stop = new google.maps.LatLng(51.126232,0.265945) ; // SAME AS START 
waypts.push({location:stop, stopover:true}); 

stop = new google.maps.LatLng(51.593165,-0.028696) ; // SAME AS END 
waypts.push({location:stop, stopover:true}); 
stop = new google.maps.LatLng(51.488874,-0.287175) ; 
waypts.push({location:stop, stopover:true}); 
stop = new google.maps.LatLng(51.440487,-0.155701) ; 
waypts.push({location:stop, stopover:true}); 

start = new google.maps.LatLng(51.126232,0.265945); // SAME AS FIRST WAYPOINT 
end = new google.maps.LatLng(51.593165,-0.028696); // SAME AS SECOND WAYPOINT 

刪除第一個航路點,他們應該從A

失蹤E啓動,您有一個稱爲optimizeWaypoints設置爲true的選項。來自https://developers.google.com/maps/documentation/javascript/directions的引用:

optimizeWaypoints(可選)指定使用提供的航點的航線可以進行優化以提供儘可能短的航線。如果爲true,則路線服務將返回waypoint_order字段中的重新排序的路標。

這會導致第二個航點被重新排序爲實際上是最後一個航點,並且因爲它們彼此重疊,與起點相同,所以只顯示後一點,並且字母E在您的地圖中缺失。

相關問題