我正在尝试从数据库中绘制几个分离的多边形(建筑物)。我从数据库中获取的数据如下所示:
<buildings>
<building build_id="94" build_gebaeude="A"
build_geoX="49.26173942769648" build_geoY="7.350542675857582"
/>
<building build_id="95" build_gebaeude="A"
build_geoX="49.26173942769648" build_geoY="7.3524094933319475"
/>
<building build_id="96" build_gebaeude="A"
build_geoX="49.26019903253632" build_geoY="7.35234512031559"
/>
<building build_id="97" build_gebaeude="A"
build_geoX="49.26032506667364" build_geoY="7.350692879562416"
/>
<building build_id="98" build_gebaeude="B"
build_geoX="49.26155738350112" build_geoY="7.362129818801918"
/>
<building build_id="99" build_gebaeude="B"
build_geoX="49.26157138692462" build_geoY="7.364275586013832"
/>
<building build_id="100" build_gebaeude="B"
build_geoX="49.260255047748224" build_geoY="7.364361416702309"
/>
<building build_id="101" build_gebaeude="B"
build_geoX="49.260311062896506" build_geoY="7.362065445785561"
/>
</buildings>
以下代码显示了我正在做什么来绘制建筑物:
for (var i = 0; i < building.length-1; i++) {
var point = new google.maps.LatLng(
parseFloat(building[i].getAttribute("build_geoX")),
parseFloat(building[i].getAttribute("build_geoY"))
);
latlngbounds.extend(point);
if( building[i].getAttribute("build_gebaeude") ==
building[i+1].getAttribute("build_gebaeude") )
{
path.push(point);
}
else {
path.push(point);
poly = new google.maps.Polygon({
paths: path,
strokeWeight: 5,
strokeOpacity: 1,
fillOpacity: 0.30,
strokeColor:'#FFFFFF',
fillColor: '#a3141d'
});
polygons.push(poly);
path.clear();
}
}
polygons[0].setMap(map);
polygons[1].setMap(map);
问题是不是所有的点都画出来了?我不明白问题出在哪里?