我有一些问题,我想要的是在谷歌地图上使用数据库中的给定坐标绘制多边形,只是为了测试我只绘制了 2 个具有不同坐标数的多边形。这是我的代码
<script>
var map;
function initialize()
{
var va = new Array();
for(var i=0;i<2;i++)
{
va[i] = new Array();
}
var x=new google.maps.LatLng(-7.175993,112.650729);
var count=new Array();
var allcoor=new Array();
var mySplitResult;
//----------Problem May Be Start Right There----------------------------------
<?php
$indeksline=0;
?>
for(var a=0;a<2;a++)
{
//To get number of coordinate
count[a] = "<?php include_once("koneksi.php");
$sql3="SELECT a.Informasi from asset a LIMIT $indeksline , 1";
$result3 = mysql_query($sql3);
$data3 = mysql_fetch_row($result3);
$pieces = explode("|", $data3[0]);
$numberOfWords = count(explode("|", $data3[0]));
echo $numberOfWords;?>";
//To get Coordinate
allcoor[a] = "<?php include_once("koneksi.php");
$sql3="SELECT a.Informasi from asset a LIMIT indeksline , 1";
$result3 = mysql_query($sql3);
$data3 = mysql_fetch_row($result3);
echo $data3[0];?>";
//Split Coordinate with delimiter |
mySplitResult = allcoor[a].split("|");
for (var j=0;j<count[a];j++)
{
va[a][j]=new google.maps.LatLng(parseFloat(mySplitResult[j].split(",")[0]),parseFloat(mySplitResult[j].split(",")[1]));
}
//Increment $indeksline that use for next polygon
<?php
$indeksline = $indeksline+1;
?>
}
var mapProp = {
center:x,
zoom:19,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
for(var i=0;i<2;i++)
{
var flightPath=new google.maps.Polygon({
path:va[i],
strokeColor:"##FF0000",
strokeOpacity:0.8,
strokeWeight:3,
fillColor:"##FF0000",
fillOpacity:0.35
});
flightPath.setMap(map);
问题出在循环中,它不会增加变量 php indeksline 并且总是绘制第一个多边形。任何人都可以帮助