gpt4 book ai didi

javascript - Leaflet Draw Plugin::如何找到折线的纬度并将其保存到数据库

转载 作者:行者123 更新时间:2023-11-28 09:08:12 27 4
gpt4 key购买 nike

我已使用函数 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);
<?
}
}

?>
}

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

最佳答案

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

关于javascript - Leaflet Draw Plugin::如何找到折线的纬度并将其保存到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16642966/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com