2
A
回答
3
有時候,簡單是關鍵。
我回答我的問題,通過使用CSS:
A線是一個表:
<table id="adp-placemark" class="adp-placemark" jstcache="0">
和B線:
<table class="adp-placemark" jstcache="0">
所以下面的CSS將改變標誌:
#adp-placemark img, .adp-placemark img {
display:none;
}
#adp-placemark {
font-weight: bold;
padding: 10px 10px 10px 30px;
background: white url(../images/map_icons/number_1.png) no-repeat left center;
}
.adp-placemark {
font-weight: bold;
padding: 10px 10px 10px 30px;
background: white url(../images/map_icons/number_2.png) no-repeat left center;
}
4
我有同樣的問題。與Jason使用CSS的解決方案類似,我使用jQuery手動將圖標圖像替換爲我自己的圖標圖像。這使我可以在地圖和方向上使用相同的圖標圖像。這還允許我在地圖或路線面板中點擊標記時使用點擊處理程序打開相同的信息窗口。我爲家庭和結束位置使用不同的圖標,併爲航點使用升序數字標記。一個令人討厭的警告是,我需要使用JavaScript計時器等待1.5秒,所以我可以確定指示完成呈現,因爲它是異步的,並且沒有回調。圖像只有添加到DOM後才能被替換。 這裏是我的代碼:
function renderDrivingDirections(directionsResponse){
var directionRenderOptions = {
map: map,
panel: directionsPanel,
suppressInfoWindows: true,
suppressMarkers: true
};
var directionsRenderer = new google.maps.DirectionsRenderer(directionRenderOptions);
directionsRenderer.setDirections(directionsResponse);
/* Replace the default map markers with custom ones for following reasons:
1) Control over icon. (Custom icons for start and finish)
2) Control over icon color (to match the action status)
3) Control infowindow that opens on marker click (Add Call/Action, add link to action details)
However, we using the default rendering for the lines, and for text output of directions. So we need to wait 1.5 seconds after load
*/
window.setTimeout(
function(){
showWaypointMarkers(directionsResponse);
showOriginDestinationMarkers();
},
1500
);
}
function showWaypointMarkers(directionsResponse) {
var routeLegs = directionsResponse.routes[0].legs;
var allImages = jQuery(directionsPanel).find("img");
for (var i = 0, len = routeLegs.length -1; i < len; i++) {
var iconUrl = "https://chart.googleapis.com/chart?chst=d_map_pin_letter_withshadow&chld=" + (i+1) + "|ffffff|000000";
var marker = new google.maps.Marker({
position: routeLegs[i+1].start_location,
map: map,
title: "Stop number: " + i,
icon: {url: iconUrl}
});
var iconImageObj = jQuery("<img src='" + iconUrl + "'>");
attachInfoWindow(marker, iconImageObj, i, routeLegs[i+1]);
allImages.eq(i+1).replaceWith(iconImageObj);
}
}
function attachInfoWindow(marker, iconImageObj, legIndex, leg) {
var infowindow = new google.maps.InfoWindow({
content: "<div><h3>Stop Number: " + legIndex + "</h3><p>" + leg.start_address + "</p><a href='#'>(Stop Details)</a></div>"
});
google.maps.event.addListener(marker, 'click', function(){ //when the marker on map is clicked open info-window
infowindow.open(map,marker);
});
iconImageObj.click(function(){ //when the marker on the driving directions is clicked, open info-window
infowindow.open(map,marker);
});
}
function showOriginDestinationMarkers(){ //here using same icon for first and last
var iconUrl = "https://chart.googleapis.com/chart?chst=d_map_pin_icon_withshadow&chld=home|000000|FFFFFF"; //home icon
new google.maps.Marker({ //add home location to map
position: homeLocation,
map: map,
title: messages.homeLocationTitle,
icon: {url: iconUrl}
});
jQuery(directionsPanel, "img").first().replaceWith("<img src='" + iconUrl + "'>"); //replace their icon with ours
jQuery(directionsPanel, "img").last().replaceWith("<img src='" + iconUrl + "'>"); //replace their icon with ours
}
要避免使用定時器,我需要解析的方向,並顯示他們自己。信息窗口具有基於航點的自定義文本和指向詳細信息頁面的鏈接。
相關問題
- 1. Google Maps API v3通過自定義圖像疊加標記?
- 2. Google Maps API v3 - 自定義標記沒有出現
- 3. Google Maps v3 API和WordPress ACF:多個自定義標記
- 4. Google Maps API v3自定義動畫標記
- 5. Google Maps API自定義標記
- 6. Google Maps API v3自定義按鈕
- 7. Google Maps JavaScript API v3基於標記動畫的已知路線
- 8. 使用Google Maps JavaScript API V3查找駕車路線
- 9. Google Maps API v3標記座標
- 10. Google Chrome中的Google Maps API v3自定義光標的熱點
- 11. Google Maps Javascript API v3路線迭代
- 12. Google Maps API v3中的路線距離
- 13. Google Maps Api v3路線不顯示
- 14. 路線沒有顯示Google Maps API V3
- 15. Google Maps API:自定義路線的路線
- 16. Google Maps API v3 - maxZoomService
- 17. Google Maps Api v3自定義InfoWindow - 「google未定義」錯誤
- 18. Google Maps Api v3自定義InfoWindow - 「google未定義」錯誤
- 19. Google Maps API v3街景「google未定義」
- 20. Google Maps API:未定義標記標題
- 21. 由於未定義變量,Google Maps API V3標記未顯示
- 22. 多標記問題(Google Maps API v3)
- 23. 刷新標記 - Google Maps JavaScript API v3
- 24. Google Maps API v3多個標記Infowindow
- 25. Google Maps JavaScript API v3的標記
- 26. 刪除標記 - Google Maps JavaScript API v3
- 27. Google Maps JS API v3標記顏色
- 28. Google Maps API V3上的限制標記
- 29. 未顯示Google Maps API v3標記
- 30. Google Maps API v3添加地圖標記
這隻適用於兩個結果。關於如何讓這個工作方式點(腿)的任意數量的任何想法? – 2012-02-09 15:44:48
@DannyC你必須設置一堆腿,獲取每個元素的CSS,並相應地設置每個元素的樣式。 – Jason 2012-02-09 16:53:41