Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
152 views
in Technique[技术] by (71.8m points)

Google maps finds locations that its API doesn't

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...