1
我需要在谷歌地圖上繪製多條路線。通過googeling我找到了2個解決方案。 1是在一個sepparate的DirectionsRenderer對象中創建和渲染每條路線。另一種解決方案(我發現here)建議將多邊形存儲在一個數組中,並一次繪出它們(這對我來說似乎是更好的解決方案)谷歌地圖得到多列折線
問題是,我無法找到一種方法獲取地圖上的所有多邊形。有沒有人有關於如何做到這一點的代碼片段?
我需要在谷歌地圖上繪製多條路線。通過googeling我找到了2個解決方案。 1是在一個sepparate的DirectionsRenderer對象中創建和渲染每條路線。另一種解決方案(我發現here)建議將多邊形存儲在一個數組中,並一次繪出它們(這對我來說似乎是更好的解決方案)谷歌地圖得到多列折線
問題是,我無法找到一種方法獲取地圖上的所有多邊形。有沒有人有關於如何做到這一點的代碼片段?
我正在使用第一種解決方案。這是我的代碼。
var map;
var polyGidis;
var polyDonus;
var pozsGidis = [];
var pozsDonus = [];
function init() {
var myOptions = {
zoom: 5,
center: new google.maps.LatLng(39.00, 35.00),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('divMap'), myOptions);
polyGidis = new google.maps.Polyline({ strokeColor: 'black', strokeOpacity: 0.8, strokeWeight: 2, map: map, zIndex: 100 });
polyDonus = new google.maps.Polyline({ strokeColor: 'red', strokeOpacity: 0.8, strokeWeight: 6, map: map, zIndex: 80 });
var polyPathGidis = polyGidis.getPath();
var polyPathDonus = polyDonus.getPath();
for (var i = 0; i < pozsGidis.length; i++) {
polyPathGidis.push(new google.maps.LatLng(pozsGidis[i].lat, pozsGidis[i].lng));
}
for (var i = 0; i < pozsDonus.length; i++) {
polyPathDonus.push(new google.maps.LatLng(pozsDonus[i].lat, pozsDonus[i].lng));
}
}