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 3 ■ CREATING YOUR FIRST MAP<br />

The map will look and work the same way, but your variables will no longer be available for outside<br />

code, thereby not cluttering the global namespace.<br />

Creating <strong>Maps</strong> for Mobile Devices<br />

Better support for mobile devices was one of the main goals for <strong>Google</strong> <strong>Maps</strong> <strong>API</strong> v3. It is specifically<br />

adapted to work well on advanced mobile devices such as the iPhone and mobile phones using the<br />

Android OS. Creating maps for these devices is done the same way as for desktop browsers, but since<br />

they have smaller screens and have other ways of interacting with the items on the screen, such as the<br />

zoom-to-pinch gesture on the iPhone, there are some considerations that need to be made.<br />

Since the screens are smaller, you probably want the map to fill the entire screen. You do this by<br />

setting the height and width of the containing the map to 100 percent.<br />

For the iPhone, there’s a special element that can be used for disabling the zoom-to-pinch<br />

behavior for the browser. The element must be positioned within the section of the web<br />

page; it looks like this:<br />

<br />

You should also be aware that there’s no such thing as hover (mouseover) on mobile devices, so you<br />

shouldn’t build functionality that relies solely on that being available.<br />

You can find more information on how to develop web pages specifically for these devices here:<br />

• Safari Dev Center (iPhone)<br />

http://developer.apple.com/safari/<br />

• Android Developers<br />

http://developer.android.com/index.html<br />

Summary<br />

In this chapter, you learned how to set up a web page and how to insert a fully functional <strong>Google</strong> map in<br />

it. The map has all the basic functionality, which means that you can pan it, zoom in and out of it, and<br />

change the map type. You now have a solid map to build from. You also learned about some of the basic<br />

features of the JavaScript language.<br />

With the knowledge gained from this chapter, you’re ready to examine how you can tweak the map<br />

to look and behave the way you want, and that’s exactly what you’re going to do in the next chapter<br />

where you will examine all the properties of the MapOptions object.<br />

43

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

Saved successfully!

Ooh no, something went wrong!