Javascript 如何删除谷歌地图的默认指针?
我需要自定义地图,使其看起来像这样: 我设法添加我自己的指针图标,并将方向样式更改为点-但默认指针仍然显示。。。。 这是我的 以下是我迄今为止所做的工作:Javascript 如何删除谷歌地图的默认指针?,javascript,google-maps,pointers,Javascript,Google Maps,Pointers,我需要自定义地图,使其看起来像这样: 我设法添加我自己的指针图标,并将方向样式更改为点-但默认指针仍然显示。。。。 这是我的 以下是我迄今为止所做的工作: map = new google.maps.Map(document.getElementById('map-canvas'), myOptions), directionsService = new google.maps.DirectionsService, directionsDisplay = ne
map = new google.maps.Map(document.getElementById('map-canvas'),
myOptions),
directionsService = new google.maps.DirectionsService,
directionsDisplay = new google.maps.DirectionsRenderer({
map: map
}),
markerA = new google.maps.Marker({
position: pointA,
map: map,
icon:'https://drive.google.com/uc?id=0B3RD6FDNxXbdVXRhZHFnV2xaS1E',
}),
markerB = new google.maps.Marker({
position: pointB,
map: map,
icon:'https://drive.google.com/uc?id=0B3RD6FDNxXbdM3E5clBqWDY5MWM',
});
我还想知道如何添加公里数总和作为工具提示,以保持其相对于路线的位置-如图所示,任何帮助都将不胜感激。好的-我完成了大部分工作,结果如下
function initMap() {
var lineSymbol = {
path: "M-20,0a20,20 0 1,0 40,0a20,20 0 1,0 -40,0",
fillColor: '#3da6f9',
fillOpacity: 1,
anchor: new google.maps.Point(0,0),
strokeWeight: 0,
strokeOutline:2,
scale: 0.2
};
var pointA = new google.maps.LatLng(51.7519, -1.2578),
pointB = new google.maps.LatLng(50.8429, -0.1313),
myOptions = {
zoom: 7,
center: pointA
},
map = new google.maps.Map(document.getElementById('map-canvas'), myOptions),
// Instantiate a directions service.
directionsService = new google.maps.DirectionsService,
directionsDisplay = new google.maps.DirectionsRenderer({
polylineOptions: {
strokeColor: '#426289',
strokeOpacity: 0.4,
strokeWeight: 5,
icons: [{
icon: lineSymbol,
offset: '0px',
repeat: '15px'
}]
},
suppressMarkers: true,
map: map
}),
markerA = new google.maps.Marker({
position: pointA,
icon: 'https://drive.google.com/uc?id=0B3RD6FDNxXbdVXRhZHFnV2xaS1E',
map: map
}),
markerB = new google.maps.Marker({
position: pointB,
icon: 'https://drive.google.com/uc?id=0B3RD6FDNxXbdM3E5clBqWDY5MWM',
map: map
});
// get route from A to B
calculateAndDisplayRoute(directionsService, directionsDisplay, pointA,
pointB);
}
function calculateAndDisplayRoute(directionsService, directionsDisplay,
pointA, pointB) {
directionsService.route({
origin: pointA,
destination: pointB,
avoidTolls: true,
avoidHighways: false,
travelMode: google.maps.TravelMode.DRIVING
}, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
}
initMap();
以下是请提供一份说明问题的报告。你的提琴没有表现出与图片相同的行为。geocodezip-谢谢-我编辑了我的帖子-结果我没有保存提琴…因此它没有更新。。。