谷歌地图找到它的API没有的位置 [英] Google maps finds locations that its API doesn't

查看:128
本文介绍了谷歌地图找到它的API没有的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下网址失败:



https://maps.googleapis.com/maps/api/geocode/json?address=Wisdom+Hospice+High+Bank +罗切斯特+肯特+英格兰& key = YOUR_KEY_GOES_HERE



结果这个程序失败:

 #!/ usr / bin / env perl 

use strict;
使用警告;
使用Geo :: Coder :: Google;
使用Data :: Dumper;

my $ gcg = Geo :: Coder :: Google-> new(apiver => 3);

my @l = $ gcg-> geocode(location =>'Wisdom Hospice,High Bank,Rochester,Kent,England');

print Data :: Dumper-> new([@ l]) - > Dump();

然而,如果我在谷歌地图上搜索智慧疗养院高银行罗切斯特肯特英国给出这个:



https://www.google.com/maps/place/Wisdom+Hospice/@51.3725664 ,0.5071468,17z / data =!3m1!4b1!4m5!3m4!1s0x47d8cce4198bb5ed:0xcc28f53d7161955d!8m2!3d51.3725631!4d0.5093408



想法?

解决方案

您应该知道地理编码API仅适用于街道地址,任何业务结果都不在范围内。



在您的例子中,'智慧临终关怀'是商业场所。在这种情况下,Places API是正确的API。



您可以执行以下Places API请求来获取此地点:



https://maps.googleapis.com/maps/api/place/textsearch/json?query=wisdom%20hospice%20high%20bank%20rochester%20kent%20england&key=YOUR_API_KEY

The following URL fails:

https://maps.googleapis.com/maps/api/geocode/json?address=Wisdom+Hospice+High+Bank+Rochester+Kent+England&key=YOUR_KEY_GOES_HERE

As a result this program fails:

#!/usr/bin/env perl

use strict;
use warnings;
use Geo::Coder::Google;
use Data::Dumper;

my $gcg = Geo::Coder::Google->new(apiver => 3);

my @l = $gcg->geocode(location => 'Wisdom Hospice, High Bank, Rochester, Kent, England');

print Data::Dumper->new([@l])->Dump();

And yet, if I search for "wisdom hospice high bank rochester kent england" at google maps it works giving this:

https://www.google.com/maps/place/Wisdom+Hospice/@51.3725664,0.5071468,17z/data=!3m1!4b1!4m5!3m4!1s0x47d8cce4198bb5ed:0xcc28f53d7161955d!8m2!3d51.3725631!4d0.5093408

Thoughts?

解决方案

You should be aware that Geocoding API works only with street addresses, any business results are out of the scope.

In your example 'Wisdom Hospice' is the business place. In such situation Places API is the right API to use.

You can execute the following Places API request to get this place:

https://maps.googleapis.com/maps/api/place/textsearch/json?query=wisdom%20hospice%20high%20bank%20rochester%20kent%20england&key=YOUR_API_KEY

这篇关于谷歌地图找到它的API没有的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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