0
有誰知道我可以如何改變我輸入到Google地圖中的曲目之一的顏色?我有兩個軌道導入其中一個我想成爲另一個紅色的藍色。我正在使用谷歌地圖將.gpx文件作爲kml圖層,這是做這件事的最好方法嗎?Google Maps Track Color
任何幫助表示讚賞。
繼承人的代碼,我(發現這個網站上的該文件中拉成GPX - 新的所有谷歌地圖編碼):
<script type="text/javascript">
function initialize() {
var myOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var ctaLayer = new google.maps.KmlLayer('http://www.walkwithjon.co.uk/ForTor.gpx');
var ctaLayer2 = new google.maps.KmlLayer('http://www.walkwithjon.co.uk/Tor2.gpx');
ctaLayer2.setMap(map);
ctaLayer.setMap(map);
var lines = xmlDoc.documentElement.getElementsByTagName("trkpt");
// read each line
for (var a = 0; a < lines.length; a++) {
// get any line attributes
var colour = lines[a].getAttribute("color");
var width = parseFloat(lines[a].getAttribute("width"));
// read each point on that line
var points = lines[a].getElementsByTagName("point");
var pts = [];
for (var i = 0; i < points.length; i++) {
pts[i] = new GLatLng(parseFloat(points[i].getAttribute("lat")),
parseFloat(points[i].getAttribute("lng")));
}
map.addOverlay(new GPolyline(pts,colour,width));
}
}
</script>