我正在使用Gmap显示起点和终点之间的方向 包括航路点。
使用Gmap DirectionService时会正确显示点,但在生成KML时不能正常工作。
我的原始输出:
我想要同样的KML但是,
在为Google地球和Gmap生成KML文件时,它将标记为
我必须在KML文件中设置的选项是什么,以显示该路线的每个点都可用。
任何人都可以帮忙吗?
我的Gmap工作代码:(这对我有好处)我希望KML的选项能够提供相同的输出。
我的原始代码:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
</head>
<body>
<div id="map-canvas" style="float:left;width:1024px;height:500px;">Map Loading...</div>
<script>
var start = "46.9502622421856, 7.93212890625";
var end = "46.97978388900174, 7.944059371948242";
var waypts = [];
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
var checkboxArray;
var mywaypoints = "46.94868026561828,7.962899208068848;46.96315067896921,7.982726097106934";
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var chicago = new google.maps.LatLng(41.850033, -87.6500523);
var mapOptions = {
zoom: 6,
center: chicago
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
directionsDisplay.setMap(map);
calcRoute();
}
function calcRoute() {
checkboxArray = mywaypoints.split(/;/);
checkboxArray.forEach(function(point) {
waypts.push({
location: point,
stopover: true,
});
});
var request = {
origin: start,
destination: end,
waypoints: waypts,
optimizeWaypoints: false,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
initialize();
</script>
</body>
</html>