Home > php教程 > php手册 > body text

gps 搜索附近坐标

WBOY
Release: 2016-06-06 19:35:07
Original
823 people have browsed it

无详细内容 无 ?phpdefine('EARTH_RADIUS', 6370.6935);function vicinity($lng, $lat, $distance = 5) {//$distance = 5;// 单位 1KM$radius = EARTH_RADIUS;$dlng = abs(rad2deg(2*asin(sin($distance/(2*$radius))/cos($lat))));$dlat = abs(rad2deg($dist

<?php

define('EARTH_RADIUS', 6370.6935);

function vicinity($lng, $lat, $distance = 5) {
	//$distance = 5;		// 单位 1KM
	$radius = EARTH_RADIUS;
	
	$dlng = abs(rad2deg(2*asin(sin($distance/(2*$radius))/cos($lat))));
	$dlat = abs(rad2deg($distance/$radius));

	$lng_left = round($lng - $dlng, 6);
	$lng_right = round($lng + $dlng, 6);
	$lat_top = round($lat + $dlat, 6);
	$lat_bottom = round($lat - $dlat, 6);
	
	return array('lng'=> array('left'=> $lng_left, 'right'=> $lng_right), 'lat'=> array('top'=> $lat_top, 'bottom'=> $lat_bottom));
}
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!