0
A
回答
2
這裏是an example,用自定義標記替換所有的標記。
這裏是an example,它只是用自定義標記替換開始和結束標記。
定製方向呈現器(呈現方向作爲天然折線和標記):
function RenderCustomDirections(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
waypts = [];
var bounds = new google.maps.LatLngBounds();
var route = response.routes[0];
var summaryPanel = document.getElementById("directions_panel");
var detailsPanel = document.getElementById("direction_details");
startLocation = new Object();
endLocation = new Object();
summaryPanel.innerHTML = "";
detailsPanel.innerHTML = '<ul>';
// For each route, display summary information.
for (var i = 0; i < route.legs.length; i++) {
var routeSegment = i + 1;
summaryPanel.innerHTML += "<b>Route Segment: " + routeSegment + "</b><br />";
summaryPanel.innerHTML += route.legs[i].start_address + " to ";
summaryPanel.innerHTML += route.legs[i].end_address + "<br />";
summaryPanel.innerHTML += route.legs[i].distance.text + "<br /><br />";
}
var path = response.routes[0].overview_path;
var legs = response.routes[0].legs;
for (i=0;i<legs.length;i++) {
if (i == 0) {
startLocation.latlng = legs[i].start_location;
startLocation.address = legs[i].start_address;
startLocation.marker = createMarker(legs[i].start_location,"start",legs[i].start_address,"green");
} else {
waypts[i] = new Object();
waypts[i].latlng = legs[i].start_location;
waypts[i].address = legs[i].start_address;
waypts[i].marker = createMarker(legs[i].start_location,"waypoint"+i,legs[i].start_address,"yellow");
}
endLocation.latlng = legs[i].end_location;
endLocation.address = legs[i].end_address;
var steps = legs[i].steps;
for (j=0;j<steps.length;j++) {
var nextSegment = steps[j].path;
for (k=0;k<nextSegment.length;k++) {
polyline.getPath().push(nextSegment[k]);
bounds.extend(nextSegment[k]);
}
}
}
detailsPanel.innerHTML += "</ul>"
polyline.setMap(map);
map.fitBounds(bounds);
endLocation.marker = createMarker(endLocation.latlng,"end",endLocation.address,"red");
// == create the initial sidebar ==
makeSidebar();
} else alert(status);
}
的createMarker功能:
function createMarker(latlng, label, html, color) {
var contentString = '<b>'+label+'</b><br>'+html;
var marker = new google.maps.Marker({
position: latlng,
draggable: true,
map: map,
icon: getMarkerImage(color),
shape: iconShape,
title: label,
zIndex: Math.round(latlng.lat()*-100000)<<5
});
marker.myname = label;
gmarkers.push(marker);
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map,marker);
});
return marker;
}
自定義圖標功能:
function getMarkerImage(iconColor) {
if ((typeof(iconColor)=="undefined") || (iconColor==null)) {
iconColor = "red";
}
if (!icons[iconColor]) {
icons[iconColor] = {
url: "mapIcons/marker_"+ iconColor +".png",
// This marker is 20 pixels wide by 34 pixels tall.
size: new google.maps.Size(20, 34),
// The origin for this image is 0,0.
origin: new google.maps.Point(0,0),
// The anchor for this image is at 6,20.
anchor: new google.maps.Point(9, 34));
}
return icons[iconColor];
}
+0
如何去除只有路標點標記?我似乎無法讓它爲我工作。我目前只加載(1)方式點。 :) – 2014-01-08 04:39:10
+0
你不僅可以壓制一個標記,你必須全部壓制它們,只爲端點製作自己的標記。使用中途停留:對於航點可能會做你想要的。 – geocodezip 2014-01-08 10:46:22
相關問題
- 1. 谷歌地圖V2阿比
- 2. 如何刪除谷歌地圖路線方向上的默認A B標記
- 3. 標記在谷歌地圖
- 4. 在谷歌地圖標記
- 5. 谷歌地圖apiv3標記替換舊
- 6. 切換谷歌地圖標記
- 7. 谷歌地圖切換標記
- 8. 谷歌地圖標記不被替換
- 9. 谷歌地圖熱圖和標記
- 10. Jquery Ajax和谷歌地圖v3 API標記 - a {或(
- 11. setTimeout更新谷歌地圖v3標記
- 12. 谷歌地圖 - 定期更新標記
- 13. 更新谷歌地圖標記位置
- 14. 更新谷歌地圖上的標記
- 15. 更新谷歌地圖標記
- 16. 谷歌地圖api V3更新標記
- 17. 如何啓用谷歌地圖標記
- 18. 谷歌地圖 - 多標記
- 19. RxJS谷歌地圖標記
- 20. 谷歌地圖標記
- 21. 谷歌地圖標記url
- 22. 谷歌地圖 - 多標記
- 23. 谷歌地圖API標記
- 24. android谷歌地圖標記
- 25. 谷歌地圖標記infowindow
- 26. 谷歌地圖標記DROP
- 27. 谷歌地圖:getSelected標記
- 28. 到標記谷歌地圖
- 29. 谷歌地圖標記
- 30. 谷歌地圖xml標記
的更多細節將好嗎?這聽起來像你有多個航點,只想刪除前兩個。你只希望前兩個被刪除?你想用一些東西代替它們嗎? – geocodezip 2012-07-27 10:40:37
我想用兩個標記替換我的自定義標記 – Asraf 2012-07-27 11:27:30