- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在寻找一种通过 PowerShell 查询 Windows 10 位置服务的方法,以十进制形式返回设备的当前纬度和经度。从 http://www.verboon.info/2013/10/powershell-script-get-computergeolocation/ 抄袭我整理了以下功能:
function Get-LatLong()
{
# Windows Location API
$mylocation = new-object -ComObject LocationDisp.LatLongReportFactory
# Get Status
$mylocationstatus = $mylocation.status
if ($mylocationstatus -eq "4")
{
# Windows Location Status Returns 4, so we're "Running"
# Get latitude and longitude from LatLongReport property
$latitude = $mylocation.LatLongReport.Latitude
$longitude = $mylocation.LatLongReport.Longitude
if ($latitude -ne $null -or $longitude -ne $null)
{
write-host "$longtitude $latitude"
}
Else
{
write-warning "Latitude or Longitude data missing"
}
}
Else
{
switch($mylocationstatus)
{
# All possible status property values as defined here:
# http://msdn.microsoft.com/en-us/library/windows/desktop/dd317716(v=vs.85).aspx
0 {$mylocationstatuserr = "Report not supported"}
1 {$mylocationstatuserr = "Error"}
2 {$mylocationstatuserr = "Access denied"}
3 {$mylocationstatuserr = "Initializing" }
4 {$mylocationstatuserr = "Running"}
}
If ($mylocationstatus -eq "3")
{
write-host "Windows Loction platform is $mylocationstatuserr"
sleep 5
Get-LatLong
}
Else
{
write-warning "Windows Location platform: Status:$mylocationstatuserr"
}
}
} # end function
当我调用该函数时,它返回:
PS C:\windows\system32> Get-LatLong
WARNING: Windows Location platform: Status:Report not supported
设备上启用了定位服务。我以管理员身份运行 PowerShell。网络搜索没有帮助。
最佳答案
如果按照代码中的注释: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317716(v=vs.85).aspx
它提到:
[The Location API object model is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Instead, to access location from a website, use the W3C Geolocation API. To access location from a desktop application, use the Windows.Devices.Geolocation API.]
并且支持的平台是:
Minimum supported client Windows 7 [desktop apps only]
结论:
我认为如何在 Windows 10 上查询位置数据的答案是使用 Geolocation API .
关于windows - 如何在PowerShell中查询Windows 10设备的经纬度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36144271/
我是一名优秀的程序员,十分优秀!