Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

Part II: Instant Gratification


If geocoding is not available for your country or needs, other solutions exist that can determine
the information you need, such as the Google scraping method covered later in this chapter.

Looking Up U.S. Information


The easiest way to resolve U.S. geocoding is to use the service provided by the geocoder.us
web site. The web site provides a number of different interfaces, including SOAP, XML-RPC,
and a basic URL interface. The information returned can be in either object, XML, or CSV
format, making it suitable for use within a wide range of applications and environments.

For example, to use the XML-RPC version of the service, use a script like the one shown in
Listing 6-1.

Listing 6-1: Using XML-RPC with geocoder.us to Look Up Address
Information

use XMLRPC::Lite;
use Data::Dumper;

my $address = XMLRPC::Lite->proxy(‘http://geocoder.us/service/xmlrpc’)
->geocode(join(‘ ‘,@ARGV))
->result;

print Dumper($address),”\n”;

Geocoding Priorities

Some readers will be surprised to see a detailed analysis of geocoding quite so late in this book.
The simple reason for this is that the importance of geocoding depends entirely on the map you
are generating.

As you will see in forthcoming chapters, the latitude and longitude information is critical to the
way you use Google Maps. However, it is also clear that if you already have the latitude and
longitude information or are using the Google Maps to locate and identify specific locations (as
used in the community and photographic examples in earlier chapters), the requirement to look
up information by address is actually a much lower priority.

Two of the more practical times to use geocoding are when converting your existing database
to include the latitude and longitude data or when looking up the information dynamically while
generating XML data for a given application.
Free download pdf