我尝试过在折线地图制作器上添加标题,但它对我不起作用。我不明白出了什么问题,或者为什么它不能正常工作。我尝试添加标题或说明,但无法使其正常工作。它不会在控制台中给我错误,但是如果我单击它,则不会显示标题。
function initialize() {
var map = new google.maps.Map(document.getElementById('map-canvas'), {
center: { lat: 42.9994443, lng: -0.0107599},
zoom: 12
});
var fromMarker = new google.maps.Marker({
map: map,
position: { lat: 43.1002647, lng: -0.0423151 },
title: 'Hello World!'
});
var toMarker = new google.maps.Marker({
map: map,
position: { lat: 42.8906, lng: -0.115006 },
title: 'Hello World!'
});
var ds = new google.maps.DirectionsService();
ds.route({
origin: fromMarker.getPosition(),
destination: toMarker.getPosition(),
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC
}, function (result, status) {
if (status == google.maps.DirectionsStatus.OK) {
console.log(result);
new google.maps.Polyline({
map: map,
path: result.routes[0].overview_path,
strokeOpacity: 1.0,
strokeWeight: 2,
geodesic: true,
icons: [{
icon: {path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW},
offset: '100%',
repeat: '40px'
}]
});
var fullPath = [];
result.routes[0].legs.forEach(function (leg) {
leg.steps.forEach(function (step) {
fullPath = fullPath.concat(step.path);
new google.maps.Polyline({
map: map,
path: step.path,
strokeColor: "red",
strokeWeight: 1
});
});
});
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
呼唤远方
相关分类