2015-07-10 22 views
-3

什么是代码来获取当前位置的经纬度在php.Later我必须使用这个经度值在谷歌地图中绘制标记。我怎样才能得到当前位置经纬度值在PHP中使用android

+0

转到此http://developer.android.com/reference/android/location/Location.html ........... .......................或者这个http://stackoverflow.com/questions/17983865/making-a-location-object-in-android-with -latitude-and-longitude-values – Hytool

回答

0

为此,您需要在php中创建一个web服务,该服务存储当前的纬度,设备的lng和 创建一个新的web服务,该纬度返回给android应用程序,您可以使用lat, lng在谷歌地图上显示标记...

+0

可以请你帮我解释一下代码吗? – Neeraja

0
create table to store lat,lng 
id,lat,lng 
than 

create store.php file 
code to store lat,lng in table in php 
$lat= $_POST['lat']; 
$lng=$_POST['lng']; 
$sql="insert into location values('null','$lat','$lng')"; 
$result=mysql_query($sql); 
if($result>0) 
{ 
    echo '1'; 
}else 
{ 
echo '0'; 
} 

call this file using url in android code 

for example 
54.123.54.195/myapp/store.php 


now to fetch the lat,lng make an new file fetch.php 

$sql="select * from location"; 
$result=mysql_query($sql); 
while($row=mysql_fetch_array($result)) 
{ 

    json_encode($row); 

} 

call the fetch.php same as above file in your android code 

for example 
54.123.54.195/myapp/fetch.php 

you will get data as json and you can use in your code to show marker 
+0

好的,先生,谢谢:) – Neeraja

相关问题