以Xamarin形式获取经纬度的设备位置 [英] Get device location in latitude-longitude in xamarin forms

查看:274
本文介绍了以Xamarin形式获取经纬度的设备位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有扫描仪,并且在扫描任何QR码时,都需要获取设备的当前位置(经纬度).我不知道如何获取位置,所以现在没有任何代码.向我建议一些方法来获取QR码扫描完成时的位置.

I have a scanner in my application, and as I am scanning any QR code I need to get a current location of device in latitude-longitude. I don't have any idea how to get location so I don't have any piece of code right now. Suggest me some ways to get location on scanning completion of QR code.

推荐答案

Geolocator插件示例:

Geolocator Plugin example:

var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync (timeoutMilliseconds: 10000);
Console.WriteLine ("Position Status: {0}", position.Timestamp);
Console.WriteLine ("Position Latitude: {0}", position.Latitude);
Console.WriteLine ("Position Longitude: {0}", position.Longitude);

参考: https://github.com/jamesmontemagno/GeolocatorPlugin

Nuget: https://www.nuget.org/packages/Xam.Plugin.地理位置定位器

这篇关于以Xamarin形式获取经纬度的设备位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆