使用地址从googlemap获取位置(纬度/经度) - 使用PowerShell [英] Get location (lat/long) from googlemap with address - Using powershell

查看:186
本文介绍了使用地址从googlemap获取位置(纬度/经度) - 使用PowerShell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个脚本,允许我使用他们的地址获取Google地图上某些位置的坐标。
为此,我使用powershell代码:

  clear-host 

$ address = Place + de + la + concorde
$ city =Paris
$ cp =75000
$ country =France

$ url = https://maps.googleapis.com/maps/api/geocode/json?address=+ $ address +++ $ city +++ $ cp +++ $ country
$ result = Invoke-WebRequest -Uri $ url
Write-Host = $ result

不幸的是我无法检索对我有意思的行,例如:
$ b $ p结果几何体位置lat



结果> geometry>位置> lng



获取特定行信息的任何想法,线路可能会改变?



谢谢!

解决方案

ConvertFrom-JSON是你的cmdlet

  $ json = Invoke-WebRequest $ url | ConvertFrom-JSON 
$ json.results.geometry.location.lat
$ json.results.geometry.location.lng

现在您正在查看JSON对象(如预期的那样),而不是线条,因此您不必担心线条位置等。


I would like to create a script that allow myself to get the coordinates of some locations on Google map using their addresses. To do this I use powershell code:

clear-host

$address = "Place+de+la+concorde"
$city = "Paris"
$cp = "75000"
$country = "France"

$url = "https://maps.googleapis.com/maps/api/geocode/json?address=" + $address + "+" + $city + "+" + $cp + "+" + $country
$result = Invoke-WebRequest -Uri $url
Write-Host = $result

Unfortunately I can not retrieve rows interesting to me, ie:

results> geometry> location> lat

and

results> geometry> location> lng

Any idea for getting a specific line information, considering that the number of lines could change ?

Thank you !

解决方案

ConvertFrom-JSON is the cmdlet you need.

$json = Invoke-WebRequest $url | ConvertFrom-JSON
$json.results.geometry.location.lat
$json.results.geometry.location.lng

Now you are looking at a JSON object (as intended) rather than lines so you won't have to worry about line position, etc.

这篇关于使用地址从googlemap获取位置(纬度/经度) - 使用PowerShell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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