【Unity】使用GPS定位经纬度
来源:互联网 发布:淘宝客鹊桥什么意思 编辑:程序博客网 时间:2024/05/18 00:11
using UnityEngine;using System.Collections;using UnityEngine.UI;public class GPS : MonoBehaviour{ private string N_Latitude; //经度 private string E_Longitude; //纬度 public Button LocationButton;// 定位按钮 void Start() { LocationButton.onClick.AddListener(() =>{// 这里需要启动一个协同程序 StartCoroutine(StartGPS()); });}IEnumerator StartGPS(){// Input.location 用于访问设备的位置属性(手持设备), 静态的LocationService位置 // LocationService.isEnabledByUser 用户设置里的定位服务是否启用 if (!Input.location.isEnabledByUser){// ios需在info.plist添加key:Privacy - Location When In Use Usage DescriptionDebug.Log("用户没有开启定位权限"); yield break;} else {// LocationService.Start() 启动位置服务的更新,最后一个位置坐标会被使用 // 定位精度10米,最小移动距离10米Input.location.Start(10.0f, 10.0f); } // 不能立刻获得定位,所以需要等待int maxWait = 20;while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0){// 暂停协同程序的执行(1秒) yield return new WaitForSeconds(1);maxWait--;}if (maxWait < 1){ Debug.Log("定位超时"); yield break;}if (Input.location.status == LocationServiceStatus.Failed){ Debug.Log("定位失败");yield break;}else{ N_Latitude = Input.location.lastData.latitude.ToString(); E_Longitude = Input.location.lastData.latitude.ToString(); Input.location.Stop(); yield return null;}}}
阅读全文
0 0
- 【Unity】使用GPS定位经纬度
- GPS定位+经纬度定位
- xamarin android使用gps定位获取经纬度
- GPS 定位经纬度
- Unity获取经纬度(GPS)
- unity获取设备经纬度(unity使用GPS)详解
- unity获取设备经纬度(unity使用GPS)详解
- unity获取设备经纬度(unity使用GPS)详解
- unity获取设备经纬度(unity使用GPS)详解
- 使用GPS经纬度定位附近地点(某一点范围内查询)
- Android GPS定位 获取经纬度
- Android GPS定位 获取经纬度
- Android GPS定位 获取经纬度
- GPS定位经纬度标准转换
- unity通过GPS定位
- 使用Gps获取经纬度
- Android GPS/WIFI定位 获取经纬度
- Android GPS定位(获取经纬度)
- JavaWeb开发模式
- java初学笔记
- python pip使用国内源
- oracle学习笔记之开山
- allegro 错误
- 【Unity】使用GPS定位经纬度
- 一篇文章,教你学会Git
- 2017.09.07工作日记
- SQL Server 的命名规则
- 欢迎使用CSDN-markdown编辑器
- SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
- linux
- 水果忍者VR原型 二
- C++杂记(1)