27.10.2014 Views

Google Maps API 3

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 1 ■ INTRODUCING THE GOOGLE MAPS <strong>API</strong><br />

The main legacy pitfall was the architecture of the old <strong>API</strong>. It was built using a synchronous model.<br />

Because of this, the browser had to download and run a lot of scripts sequentially before it could actually<br />

display the map. A major goal with the new <strong>API</strong> was to modularize it so that the necessary code is loaded<br />

first, displaying the map, and everything else is loaded later.<br />

The result of the efforts of the <strong>API</strong> team is an <strong>API</strong> that is significantly faster on mobile platforms such<br />

as iPhone and Android and also a lot faster on desktop platforms.<br />

■ Tip If you want to know more about how the new <strong>API</strong> was built and what led to those decisions, I recommend<br />

you watch the first part of the talk, Performance Tips for Geo <strong>API</strong> Mashups, from the 2009 <strong>Google</strong> I/O developer<br />

conference where Marcelo Camelo explains it all. See http://code.google.com/intl/sv-SE/events/io/2009/<br />

sessions/PerformanceTipsGeoApiMashups.html.<br />

Mapping Fundamentals<br />

In the next chapter, you’ll get your hands dirty and start creating your very first map. But before you do<br />

that, a basic understanding of how mapping works will make it easier to learn the <strong>API</strong>. Actually, you<br />

don’t need to worry that much about how maps work since the <strong>Google</strong> <strong>Maps</strong> <strong>API</strong> takes care of most of it<br />

for you. You do, however, need to understand how coordinates work.<br />

Coordinates<br />

Coordinates are used to express locations in the world. There are several different coordinate systems.<br />

The one being used in <strong>Google</strong> <strong>Maps</strong> is the Word Geodetic System 84 (WGS 84), which is the same system<br />

the Global Positioning System (GPS) uses. The coordinates are expressed using latitude and longitude.<br />

You can think of these as the y and x values in a grid.<br />

■ Note A source of confusion is the order the values are presented. Although the values in a grid are normally<br />

presented with the x value first and the y value second, latitude and longitude do the opposite. They are presented<br />

with the latitude value (the equivalent of y) first and the longitude value (the equivalent of x) second.<br />

Latitude measures from south to north, and longitude measures from west to east. At the equator,<br />

the latitude is 0. This means that everything below the equator (the south hemisphere) has a negative<br />

number, and everything above it (the north hemisphere) has a positive number. Similarly, there’s a zero<br />

line for the longitude too. It’s called the prime meridian, and for historical reasons it runs through<br />

Greenwich, England. Every position that is located east of this line has a positive number, and everything<br />

west has a negative number (Figure 1-2).<br />

4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!