【文件属性】:
文件名称:判断一个点是否在一个多边形范围内
文件大小:2KB
文件格式:PHP
更新时间:2018-10-01 04:39:27
GPS 经纬度 多边形 地图 百度地图
判断GPS经纬度坐标点是否在一个多边形范围内,测试代码如下:
$point = array('lng'=>'116.293616', 'lat'=>'39.884003');
$point = array('lng'=>'116.260846', 'lat'=>'39.879574');
$point = array('lng'=>'116.256247', 'lat'=>'39.790925');
$point = array('lng'=>'116.16771', 'lat'=>'39.771406');
$point = array('lng'=>'116.411474', 'lat'=>'39.74922');
//$point = array('lng'=>'116.652938', 'lat'=>'39.735016');
$areaJson = '[{"lng":116.231525,"lat":40.003488},{"lng":116.504035,"lat":39.995529},{"lng":116.627067,"lat":39.865397},{"lng":116.642015,"lat":39.745669},{"lng":116.315463,"lat":39.730577},{"lng":116.057901,"lat":39.837922},{"lng":116.351108,"lat":39.859194},{"lng":116.293616,"lat":39.884003}]';
var_dump(isPointInPolygon($point, json_decode($areaJson, true)));
网友评论
- 很实用的一个工具类