ano*_*nym 2 javascript google-maps google-maps-api-3 google-maps-markers
我想在地图上显示地点名称,而不是标签 A 和 B。如何在 Google Maps Directions API 中执行此操作?例如, just Startand Endor Miami Portto Miami Tower。
CODE
let directionsDisplay;
let directionsService = new google.maps.DirectionsService();
let map;
directionsDisplay = new google.maps.DirectionsRenderer();
let myOptions = {
mapTypeId: google.maps.MapTypeId.ROADMAP,
};
let mapArea = document.getElementById("map_canvas_track_order");
map = new google.maps.Map(mapArea, myOptions);
directionsDisplay.setMap(map);
let start = `25.757928, -80.192897`;
let end = `25.771969, -80.191235`;
let request = {
origin:start,
destination:end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
Run Code Online (Sandbox Code Playgroud)
CURRENT MAP PREVIEW
您可以隐藏默认标记A并B使用suppressMarkers属性作为true.
directionsDisplay = new google.maps.DirectionsRenderer({map: map, suppressMarkers: true});
Run Code Online (Sandbox Code Playgroud)
然后使用Marker.在终点处制作自己的标记。
var marker = new google.maps.Marker({
position: ,
label: "~what you want~",
map: map
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1357 次 |
| 最近记录: |