我使用函数getLatlngs()
获取了折线的latlng。 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);
<?
}
}
?>
}
如何在地图上绘制这些latlng?我也使用php split方法来拆分latlngs但没有成功。
答案 0 :(得分: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