1

我已经使用函数获取了多段线的纬度getLatlngs()。Latlng 以类似的格式保存在数据库中"LatLng(-37.76949, 175.26481),LatLng(-37.77211, 175.26884),LatLng(-37.77323, 175.26532)"

$query = "Select * from geofence where geo_type=3";
$result = pg_exec($db_handle,$query);
if($result) {
for($row = 0; $row < pg_numrows($result); $row++){
    $fence_id   = pg_result($result,$row,'geo_id');
    $fence_nam  = strtoupper(pg_result($result,$row,'geo_name'));
    $fence_typ  = pg_result($result,$row,'geo_type');
    $fence_coord    = pg_result($result,$row,'geo_coord');

?>
line<? echo $fence_id; ?> = new L.Polyline([new L.<? echo $fence_coord ?>).addTo(map);
<?      
    }
}

?>
}

如何在地图上绘制这些纬度?我也使用 php split 方法来拆分 latlngs 但没有成功。

4

1 回答 1

0
I used javascript function like this

function splitfunc(str){
    var a = ""+str;
    var b= replaceAll(/\)\,/g,":",a);
    var c= replaceAll(/LatLng\(/g," ",b);
    var d= replaceAll(/\)/g," ",c);
    return d;
}

function replaceAll(find, replace, str) {       
    return str.replace(find, replace);
}

Using these functions you can save Lat Long in any format
于 2013-05-21T07:15:04.603 回答