<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      1.通過GPS獲取經(jīng)緯度

      直接上代碼了

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.UI;
      
      public class GetGPS : MonoBehaviour
      {
          string GetGps = "";
          //public Button updateBtn;
      
          Vector2 jingWei = new Vector2();
          // Start is called before the first frame update
          void Start()
          {
              #region 初始化一次位置
              StartCoroutine(StartGPS());
              GetGps = "N:" + Input.location.lastData.latitude + " E:" + Input.location.lastData.longitude;
              jingWei.x = Input.location.lastData.latitude;
              jingWei.y = Input.location.lastData.longitude;
              GetGps = GetGps + " Time:" + Input.location.lastData.timestamp;
              //Debug.Log(GetGps);
              #endregion
      
              //updateBtn.onClick.AddListener(updateGps);
      
      
      
          }
      
          /// <summary>
          /// 刷新位置信息
          /// </summary>
          public Vector2 updateGps()
          {
      
      
              StartCoroutine(StartGPS());
              GetGps = "N:" + Input.location.lastData.latitude + " E:" + Input.location.lastData.longitude;
              jingWei.x = Input.location.lastData.latitude;
              jingWei.y = Input.location.lastData.longitude;
              GetGps = GetGps + " Time:" + Input.location.lastData.timestamp;
              Debug.Log(GetGps);
              return jingWei;
          }
          IEnumerator StartGPS()
          {
              // Input.location 用于訪問設(shè)備的位置屬性(手持設(shè)備), 靜態(tài)的LocationService位置  
              // LocationService.isEnabledByUser 用戶設(shè)置里的定位服務(wù)是否啟用  
              if (!Input.location.isEnabledByUser)
              {
                  GetGps = "isEnabledByUser value is:" + Input.location.isEnabledByUser.ToString() + " Please turn on the GPS";
                  yield return false;
              }
      
              // LocationService.Start() 啟動(dòng)位置服務(wù)的更新,最后一個(gè)位置坐標(biāo)會(huì)被使用  
              Input.location.Start(10.0f, 10.0f);
      
              int maxWait = 20;
              while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
              {
                  // 暫停協(xié)同程序的執(zhí)行(1秒)  
                  yield return new WaitForSeconds(1);
                  maxWait--;
              }
      
              if (maxWait < 1)
              {
                  GetGps = "Init GPS service time out";
                  yield return false;
              }
      
              if (Input.location.status == LocationServiceStatus.Failed)
              {
                  GetGps = "Unable to determine device location";
                  yield return false;
              }
              else
              {
                  GetGps = "N:" + Input.location.lastData.latitude + " E:" + Input.location.lastData.longitude;
                  jingWei.x = Input.location.lastData.latitude;
                  jingWei.y = Input.location.lastData.longitude;
                  GetGps = GetGps + " Time:" + Input.location.lastData.timestamp;
                  yield return new WaitForSeconds(100);
              }
          }
          /// <summary>
          /// 停止刷新位置(節(jié)省手機(jī)電量)
          /// </summary>
          void StopGPS()
          {
              Input.location.Stop();
          }
      }

       

      2.通過百度的逆地理編碼API進(jìn)行經(jīng)緯度跟中文地址的轉(zhuǎn)化

      進(jìn)入百度地圖開放平臺(tái)

      https://lbsyun.baidu.com/apiconsole/quota#/home

       創(chuàng)建服務(wù)端類型的應(yīng)用

       

      這是逆地理編碼的接口說明:

      https://lbsyun.baidu.com/faq/api?title=webapi/guide/webservice-geocoding-abroad-base

      這是API調(diào)用的問題文檔: https://lbsyun.baidu.com/faq/search?id=260

      下面上代碼:

      using Newtonsoft.Json;
      using Newtonsoft.Json.Linq;
      using System.Collections;
      using UnityEngine;
      
      public class AddressTool : MonoBehaviour
      {
          //https://api.map.baidu.com/reverse_geocoding/v3/?ak=您的ak&output=json&coordtype=wgs84ll&location=31.225696563611,121.49884033194
          //這里使用的是百度開放平臺(tái) 應(yīng)用類別:服務(wù)端 的AK
          string ak = "";
          float latitude;
          float longitude;
          string url;
          //string url = "https://api.map.baidu.com/reverse_geocoding/v3/?ak="+ ak + "&output=json&coordtype=wgs84ll&location=";
      
          [SerializeField] GetGPS getGPS;
          void Start()
          {
              //北京
              latitude = 40f;
              longitude = 116.467f;
              GetDiDian();
              //天津
              latitude = 39.12169f;
              longitude = 117.7334f;
              GetDiDian();
      
              //url = "https://api.map.baidu.com/reverse_geocoding/v3/?ak=" + ak + "&output=json&coordtype=wgs84ll&location="+ latitude+","+ longitude;
              /*url = "https://api.map.baidu.com/reverse_geocoding/v3/?ak=" + ak + "&output=json&coordtype=wgs84ll&extensions_poi=1&location=" + latitude + "," + longitude;
      
              StartCoroutine(Request());*/
              GetDiDian();
          }
          void GetDiDian()
          {
              url = "https://api.map.baidu.com/reverse_geocoding/v3/?ak=" + ak + "&output=json&coordtype=wgs84ll&extensions_poi=1&location=" + latitude + "," + longitude;
      
              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);
                  //Debug.Log(req.content.address_detail.city + " X: " + req.content.point.x + " Y: " + req.content.point.x);
      
                  string ss=www.text;
                  //Object newStudent = JsonConvert.DeserializeObject<Object>(www.text);
                  //Object newStudent = JsonMgr.DeSerialize<Object>(ss);
                  /*JsonData newStudent = JsonConvert.DeserializeObject<JsonData>(www.text);
                  Debug.Log(newStudent.status);
                  Debug.Log(newStudent.result);*/
                  JObject jo = (JObject)JsonConvert.DeserializeObject(ss);
                  Debug.Log(jo);
                  Debug.Log(jo["result"]);
                  Debug.Log(jo["result"]["pois"]);
                  Debug.Log(jo["result"]["pois"][0]["addr"]);
                  Debug.Log(jo["result"]["pois"][0]["name"]);
                  Debug.Log(jo["result"]["pois"][0]["uid"]);
              }
          }
      }
      public class JsonMgr
      {
          public static string Serialize<T>(T t)
          {
              return JsonConvert.SerializeObject(t);
          }
      
          public static T DeSerialize<T>(string json)
          {
              return JsonConvert.DeserializeObject<T>(json);
          }
      }
      class JsonData
      {
          public int status;
          public JsonResult result;
      }
      class JsonResult
      {
          public JsonLocation location;//經(jīng)緯度
          string formatted_address_poi;//機(jī)構(gòu)化地址
      }
      class JsonLocation
      {
          public float lng;//經(jīng)度值
          public float lat;//緯度值
      }

      注意:

      逆地理編碼的時(shí)候需要用GetGPS.cs搭配使用

      而且需要提前注冊(cè)號(hào)百度地圖開放平臺(tái)的服務(wù)端類型的應(yīng)用,并獲取AK碼

      這里解析JSON時(shí),使用了Newtonsoft,分享鏈接如下:

      鏈接:https://pan.baidu.com/s/1zoXDUr03miEKgnAk__U5YQ?pwd=cdbh
      提取碼:cdbh

       

      posted on 2024-07-11 11:04  凌落成迷  閱讀(249)  評(píng)論(0)    收藏  舉報(bào)

      主站蜘蛛池模板: 久久久久无码国产精品不卡| 中文字幕一区有码视三区| 麻豆一区二区三区蜜桃免费| 开心五月婷婷综合网站| 激情综合五月丁香亚洲| 欧美黑人巨大videos精品| 亚洲毛片多多影院| 久久88香港三级台湾三级播放| 国产一区国产二区在线视频| 久久日产一线二线三线| 无码福利写真片视频在线播放| 亚洲精品日韩中文字幕| 国产成人久久777777| 色悠悠国产精品免费观看| 无码一区二区三区AV免费| 综合色一色综合久久网| 日本熟妇浓毛| 日韩在线观看中文字幕| 国产成人午夜福利院| 久久丁香五月天综合网| 囯产精品久久久久久久久久妞妞| 无码人妻av免费一区二区三区| 国产精品综合av一区二区| 亚洲熟妇色xxxxx亚洲| 亚洲综合欧美在线…| 人妻精品动漫H无码中字| 中国丰满少妇人妻xxx性董鑫洁 | 天堂mv在线mv免费mv香蕉| 精品嫩模福利一区二区蜜臀| av性色av久久无码ai换脸| 日日麻批免费40分钟无码| 亚洲av二区国产精品| 国产精品久久久久久久久电影网| 久久久久亚洲精品无码系列| 日本免费精品| 中文字幕亚洲精品人妻| 蜜臀视频在线观看一区二区| 久久精品国产免费观看频道| 亚洲狼人久久伊人久久伊| 国产精品自在线拍国产手机版| 龙岩市|