/**
* 高德地图画电子围栏
* $key 需要填写
*/
function DrFence($radius,$c_lon,$c_lat){
$curl = new Curl\Curl();
$url = 'http://restapi.amap.com/v3/assistant/coordinate/convert?locations='.substr($c_lon,0,10).','.substr($c_lat,0,9).'&coordsys=gps&output=json&key=$key';
$rst = $curl->get($url);
$rst = json_decode($rst->response,true);
if($rst['status']==1){
$locations=$rst['locations'];
list($c_lon,$c_lat) = explode(',',$locations);
}
$r = (double)6371000.79;
$numpoints = 360;
$phase = 2 * M_PI/$numpoints;
for ($i=0;$i
/*计算坐标点*/
$dx = ($radius * cos($i * $phase));
$dy = ($radius * sin($i * $phase));
/**
* 转换成坐标
*/
$f_lon = $c_lon + $dx / ($r * cos($c_lat * M_PI/180) * M_PI / 180);
$f_lat = $c_lat + $dy / ($r * M_PI / 180);
$str[] = $f_lon.','.$f_lat;
}
$str = implode(';',$str);
$zoom = 17;
return 'http://restapi.amap.com/v3/staticmap?zoom='.$zoom.'&size=1000*500&paths=3,0x666fff,1,,:'.$str.'&key=$key';
}
使用高德地图画圆
Bill Zhang