【问题标题】:Powershell: Getting GPS Coordinates in Windows 10 - Using Windows Location API?Powershell:在 Windows 10 中获取 GPS 坐标 - 使用 Windows 位置 API?
【发布时间】:2018-02-27 11:49:07
【问题描述】:

我正在寻找一种使用 Windows 定位 API 从 powershell 脚本收集内部 GPS 数据的方法,因为 Windows 定位平台不再能够满足需求。以前,有一个 com 对象可供使用。

有没有办法在 Windows 10 中实现这一点?

【问题讨论】:

  • 更多解决方案here.

标签: powershell geolocation gps windows-10 windows-locationapi


【解决方案1】:

一个使用System.Device.Location方法的例子,这应该是你要找的。​​p>

Add-Type -AssemblyName System.Device #Required to access System.Device.Location namespace
$GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher #Create the required object
$GeoWatcher.Start() #Begin resolving current locaton

while (($GeoWatcher.Status -ne 'Ready') -and ($GeoWatcher.Permission -ne 'Denied')) {
    Start-Sleep -Milliseconds 100 #Wait for discovery.
}  

if ($GeoWatcher.Permission -eq 'Denied'){
    Write-Error 'Access Denied for Location Information'
} else {
    $GeoWatcher.Position.Location | Select Latitude,Longitude #Select the relevent results.
}

【讨论】:

    【解决方案2】:

    确保已设置位置。否则它会输出“拒绝访问位置信息”

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多