我想在同谷歌地圖繪製多個多邊形,我需要做的是從一個列表框讀latlngs,他們是這樣說的:谷歌地圖多邊形
LAT1,lng1,1 LAT2,lng2 ,1 lat3,lng3,1 LAT1,lng1,2 LAT2,lng2,2 lat3,lng3,2
和根據該值在合適的(1或2),我將讀取相應latlns和繪製多邊形,實際上我是這樣做的,在我的循環中,多邊形是繪製的,但是有一條線連接它們,我該怎麼辦?,我的意思是,如何繪製多邊形而不連接這條連線?你非常感謝!
這裏是我的代碼:
<script type="text/javascript">
var bermudaTriangle=[];
var places = [];
var geoDataSplit;
function initialize() {
var mapDiv = document.getElementById('map_canvas');
var coords = document.getElementById("selPoly");
var map = new google.maps.Map(mapDiv, {
center: new google.maps.LatLng(19.3162200000000, -99.2204930000000),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var latlng;
for (var i = 0; i < coords.options.length; i++)
{
var geoData = coords.options[i].text;
geoDataSplit = geoData.split(",");
var counter = geoDataSplit[2];
for (geoDataSplit[2] = 1; geoDataSplit[2] <= 2; geoDataSplit[2]++)
{
if (counter == geoDataSplit[2]) {
latlng = new google.maps.LatLng(parseFloat(geoDataSplit[0]), parseFloat(geoDataSplit[1]));
places.push(latlng);
bermudaTriangle = new google.maps.Polygon({
paths: places,
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.35
});
}
}
}
bermudaTriangle.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body style="font-family: Arial; border: 0 none;">
<form id="form1" runat="server">
<div>
<asp:ListBox ID="selPoly" runat="server"></asp:ListBox>
</div>
</form>
<div id="map_canvas" style="width: 1024px; height: 768px"></div>
</body>
什麼是精確值由'VAR COORDS =的document.getElementById(「selPoly」)返回' – andresf
是LAT/LNGS的combinatins和Id,例如19.4646565,-99.43435353,1所以我讓拆分得到每個值 – Emilio