此方法仅能获取当前IP所在城市的位置
废话不多说直接上代码
public class GpsTest : MonoBehaviour {
string url = "http://api.map.baidu.com/location/ip?ak=bretF4dm6W5gqjQAXuvP0NXW6FeesRXb&coor=bd09ll";
void Start()
{
StartCoroutine(Request());
}
IEnumerator Request()
{
WWW www = new WWW(url);
yield return www;
if (string.IsNullOrEmpty(www.error))
{
Debug.Log(www.text);
ResponseBody req = JsonConvert.DeserializeObject<ResponseBody>(www.text);
object a= JsonConvert.DeserializeObject(www.text);
Debug.Log(a.ToString());
Debug.Log(req.content.address_detail.city + " X: " + req.content.point.x + " Y: " + req.content.point.y);
}
}
public class ResponseBody
{
public string address;
public Content content;
public int status;
}
public cl