GeolocationExtensions.GetLocationAsync 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
GetLocationAsync(IGeolocation) |
返回设备的当前位置。 |
GetLocationAsync(IGeolocation, GeolocationRequest) |
返回设备的当前位置。 |
GetLocationAsync(IGeolocation)
- Source:
- Geolocation.shared.cs
- Source:
- Geolocation.shared.cs
返回设备的当前位置。
public:
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task<Microsoft::Maui::Devices::Sensors::Location ^> ^ GetLocationAsync(Microsoft::Maui::Devices::Sensors::IGeolocation ^ geolocation);
public static System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location?> GetLocationAsync (this Microsoft.Maui.Devices.Sensors.IGeolocation geolocation);
static member GetLocationAsync : Microsoft.Maui.Devices.Sensors.IGeolocation -> System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location>
<Extension()>
Public Function GetLocationAsync (geolocation As IGeolocation) As Task(Of Location)
参数
- geolocation
- IGeolocation
调用此方法时所针对的对象。
返回
包含 Location 当前位置信息的对象; null
如果无法确定位置,则为 。
注解
如果需要,将在运行时请求位置权限。 可能仍需要在应用清单中声明某些内容。
适用于
GetLocationAsync(IGeolocation, GeolocationRequest)
- Source:
- Geolocation.shared.cs
- Source:
- Geolocation.shared.cs
返回设备的当前位置。
public:
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task<Microsoft::Maui::Devices::Sensors::Location ^> ^ GetLocationAsync(Microsoft::Maui::Devices::Sensors::IGeolocation ^ geolocation, Microsoft::Maui::Devices::Sensors::GeolocationRequest ^ request);
public static System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location?> GetLocationAsync (this Microsoft.Maui.Devices.Sensors.IGeolocation geolocation, Microsoft.Maui.Devices.Sensors.GeolocationRequest request);
static member GetLocationAsync : Microsoft.Maui.Devices.Sensors.IGeolocation * Microsoft.Maui.Devices.Sensors.GeolocationRequest -> System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location>
<Extension()>
Public Function GetLocationAsync (geolocation As IGeolocation, request As GeolocationRequest) As Task(Of Location)
参数
- geolocation
- IGeolocation
调用此方法时所针对的对象。
- request
- GeolocationRequest
确定设备位置时要使用的条件。
返回
包含 Location 当前位置信息的对象; null
如果无法确定位置,则为 。
注解
如果需要,将在运行时请求位置权限。 可能仍需要在应用清单中声明某些内容。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈