0
我已經實現了谷歌地圖加入標記在谷歌地圖上的折線。折線正在顯示,但它試圖連接所有的點(也有一些孤立的點),這是創建不規則的形狀。請點擊以下鏈接查看快照。不規則多段線谷歌地圖
irregular polyline google maps irregular polyline google maps_1
我需要reomve是不規則的形狀。有什麼辦法可以做到嗎?如果不是,我應該去使用谷歌地圖的其他功能來實現相同的功能。我正在使用MySQL數據庫,從中導入lat long,並使用xml輸出顯示在地圖上。每一個幫助將不勝感激。如果您對我的疑問不清楚,請隨時索要詳細解釋。我很樂意澄清每一點。
我的代碼如下
function load() {
var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(23.00000, 80.00000),
zoom: 5,
mapTypeId: 'roadmap'
});
var infoWindow = new google.maps.InfoWindow;
var flightPlanCoordinates = new google.maps.MVCArray();
var bounds = new google.maps.LatLngBounds();
// Change this depending on the name of your PHP file
downloadUrl("navigatormapxml.php", function(data) {
var xml = data.responseXML;
var gpsdata = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < gpsdata.length; i++) {
var id = gpsdata[i].getAttribute("id");
var point = new google.maps.LatLng(
parseFloat(gpsdata[i].getAttribute("lat")),
parseFloat(gpsdata[i].getAttribute("lng")));
flightPlanCoordinates.insertAt(flightPlanCoordinates.length, point);
var speed = gpsdata[i].getAttribute("speed");
var altitude = gpsdata[i].getAttribute("altitude");
var html = "<b>Accuracy = +/- </b>" + id + "<br/><b> Speed = </b>" + speed + " Kmph";
var icon = customIcons[id] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon,
shadow: icon.shadow
});
bounds.extend(point);
map.fitBounds(bounds);
map.panToBounds(bounds);
bindInfoWindow(marker, map, infoWindow, html);
}
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 5
});
flightPath.setMap(map);
});
}