在php中获取当前位置的纬度和经度的代码是什么。后来我必须使用这个lat-long值来绘制谷歌地图中的标记。
答案 0 :(得分:0)
为此你需要在php中创建一个web服务,它存储设备的当前lat,lng和 创建一个新的Web服务,将此lat,lng返回到Android应用程序,您可以使用lat,lng在谷歌地图上显示标记......
答案 1 :(得分: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