php獲取經緯度
A. 怎樣根據具體地址計算經緯度 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)
B. 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>
C. 如何用PHP獲取到百度地圖坐標或者經緯度
是傳入地址獲取地址的經緯度嗎?
以下是一個關於地理編碼的簡單示例。發送一個地址是「網路大廈」的請求,返回該地址對應的地理坐標。發送請求的url如下:
$return = file_get_contents(http://api.map..com/geocoder/v2/?address=網路大廈&output=json&ak=);
這樣就獲取到返回的數據拉
D. 在php裡面 怎麼根據地址取得經緯度。google。 地址是在一組數值(很多個地址,要批量處理)
去php手冊里找函數吧
E. php能不能獲取手機gps信息,從而得到具體經緯度
PHP是運行在伺服器端的喲~能不能獲取GPS相關信息,完全取決於客戶端向伺服器發請求時有沒有帶上這些數據
F. 微信開發,php獲取用戶地理位置,求php解析xml並輸出經緯度的方法
<?php
$doc=newDOMDocument();
$doc->load("test.xml");
$latitude=$doc->getElementsByTagName("Latitude")->item(0)->nodeValue;
$longitude=$doc->getElementsByTagName("Longitude")->item(0)->nodeValue;
$precision=$doc->getElementsByTagName("Precision")->item(0)->nodeValue;
echo"Latitude:".$latitude."<br>";
echo"Longitude:".$longitude."<br>";
echo"Precision:".$precision."<br>";
?>
G. PHP怎麼得到百度地圖的經緯度
/**
* 中國正常GCJ02坐標---->網路地圖BD09坐標
* 騰訊地圖用的也是GCJ02坐標
* @param double $lat 緯度
* @param double $lng 經度
*/
function Convert_GCJ02_To_BD09($lat,$lng){
$x_pi = 3.14159265358979324 * 3000.0 / 180.0;
$x = $lng;
$y = $lat;
$z =sqrt($x * $x + $y * $y) + 0.00002 * sin($y * $x_pi);
$theta = atan2($y, $x) + 0.000003 * cos($x * $x_pi);
$lng = $z * cos($theta) + 0.0065;
$lat = $z * sin($theta) + 0.006;
return array('lng'=>$lng,'lat'=>$lat);
}
/**
* 網路地圖BD09坐標---->中國正常GCJ02坐標
* 騰訊地圖用的也是GCJ02坐標
* @param double $lat 緯度
* @param double $lng 經度
* @return array();
*/
function Convert_BD09_To_GCJ02($lat,$lng){
$x_pi = 3.14159265358979324 * 3000.0 / 180.0;
$x = $lng - 0.0065;
$y = $lat - 0.006;
$z = sqrt($x * $x + $y * $y) - 0.00002 * sin($y * $x_pi);
$theta = atan2($y, $x) - 0.000003 * cos($x * $x_pi);
$lng = $z * cos($theta);
$lat = $z * sin($theta);
return array('lng'=>$lng,'lat'=>$lat);
}
H. php能不能獲取手機gps信息,從而得到具體經緯度
可以得到的
html5有獲取地理位置的api,即getCurrentPosition()方法,可以得到經緯度,經測試蘋果和諾基亞手機獲取的位置很精確,安卓根據各個機型而出現的偏差不同
可以獲取ip,然後使用網路地圖api,轉化成經緯度
I. php的 ip 定位,經緯度至少精確到鎮,附上源碼和詳解
ip定位一般對於電腦來說的,精確到鎮有點難,淘寶的ip api服務,只能精確到區,或者市
手機的話,你需要獲取位置,位置會因為手機質量的好壞,偏差很大,蘋果和諾基亞手機定位很准,安卓各種機型,各種偏差,使用手機定位的是,html5有獲取定位的方法,然後得到經緯度,發到網路地圖 api,獲取更精確的地址,
ip定位想要那麼精確,有點難,你得找個好點的ip庫服務,達到你要的精讀就行
J. 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;
}