⑴ 用php代碼根據經緯度,如何獲得城市名
調用第三方介面。
⑵ php 計算經緯度之間相差多少公里
//php 計算地圖上兩個坐標之間的距離
define('EARTH_RADIUS', 6378.137);//地球半徑,假設地球是規則的球體
define('PI', 3.1415926);
/**
* 計算兩組經緯度坐標 之間的距離
* params :lat1 緯度1; lng1 經度1; lat2 緯度2; lng2 經度2; len_type (1:m or 2:km);
* return m or km
*/
function GetDistance($lat1, $lng1, $lat2, $lng2, $len_type = 1, $decimal = 2)
{
$radLat1 = $lat1 * PI ()/ 180.0; //PI()圓周率
$radLat2 = $lat2 * PI() / 180.0;
$a = $radLat1 - $radLat2;
$b = ($lng1 * PI() / 180.0) - ($lng2 * PI() / 180.0);
$s = 2 * asin(sqrt(pow(sin($a/2),2) + cos($radLat1) * cos($radLat2) * pow(sin($b/2),2)));
$s = $s * EARTH_RADIUS;
$s = round($s * 1000);
if ($len_type --> 1)
{
$s /= 1000;
}
return round($s, $decimal);
}
echo GetDistance(39.908156,116.4767, 39.908452,116.450479, 1);//輸出距離/米
⑶ thinkPHP3.2 經緯度怎麼做
使用插件,網路地圖API都可以獲得經緯度
⑷ php根據經緯度獲取地理位置
這種功能,只能調用第三方的介面了,網路地圖API就有這個介面addressComponents,逆地址解析,參考方法如下:
<GeocoderSearchResponse>
<status>OK</status>
<result>
<location>
<lat>38.990998</lat>
<lng>103.645966</lng>
</location>
<formatted_address>甘肅省武威市民勤縣</formatted_address>
<business/>
<addressComponent>
<streetNumber/>
<street/>
<district>民勤縣</district>
<city>武威市</city>
<province>甘肅省</province>
</addressComponent>
<cityCode>118</cityCode>
</result>
</GeocoderSearchResponse>
⑸ php怎樣獲取當前位置的經緯度
隨著 Google Maps API 的普及,開發人員常常需要獲得某一特定地點的經度和緯度。這個非常有用的函數以某一地址作為參數,返回一個數組,包含經度和緯度數據。
function getLatLong($address){
if (!is_string($address))die("All Addresses must be passed as a string");
$_url = sprintf('<a href="http://maps.google.com/maps?output=js&q=%s">http://maps.google.com/maps?output=js&q=%s',rawurlencode($address));
$_result = false;
if($_result = file_get_contents($_url)) {
if(strpos($_result,'errortips') > 1 || strpos($_result,'Did you mean:') !== false) return false;
preg_match('!center:\\s*{lat:\\s*(-?\\d+\\.\\d+),lng:\\s*(-?\\d+\\.\\d+)}!U', $_result, $_match);
$_coords['lat'] = $_match[1];
$_coords['long'] = $_match[2];
}
return $_coords;
}
⑹ PHP 查詢離我最近的 店鋪
POST一個位置坐標後,根據位置坐標計算一個區域,把區域里的所有店鋪提取出來 再用距離公式計算出距離,然後就是簡單的數組排序了
⑺ php 怎麼根據一地的經緯度計算多個地方之間的距離
你需要知道你已經得到的經緯度是谷歌的還是網路的。
我之前做過一個團購的搜附近的美食計算距離,資料庫存著每個店鋪的經緯度,APP會獲取用戶的經緯度來進行比較。
我做的很久了,代碼找不到了。不過我的代碼是在網上搜得,代碼大概有地球半徑什麼的數學運算,代碼也沒多少。就是計算復雜。
你網路搜吧。我忘記在哪找到的了
⑻ 在php裡面 怎麼根據地址取得經緯度。google。 地址是在一組數值(很多個地址,要批量處理)
去php手冊里找函數吧
⑼ 怎樣根據具體地址計算經緯度 php
首先將該點的經緯度(l1,b1)利用高斯正算計算出在某個坐標系下的投影坐標(x1,y1)。
(x1,y1)
=
gk(l1,b1)
gk()代表高斯克呂格投影
然後根據距離和方位角s,alpha,計算出另一點的坐標(x2,y2)
x2
=
x1+
s*cos(alpha)
y2
=
y2+
s*sin(alpha)
最後利用高斯反算即可計算出另一點的經緯度(l2,b2)
⑽ php 根據經緯度 獲得 城市名
嘿嘿 這分數你應該要給我了 我收藏的好玩意終於可以拿出來分享了
http://api.map..com/geocoder?location=30.990998,103.645966&output=xml&key=
打開這個網址你就會發現奇跡,不要用360瀏覽器打開呢 360垃圾 打開的時候總是崩潰掉
中間的location表示坐標 格式:維度,經度