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 />

<br />

My first map<br />

<br />

<br />

<br />

The Doctype<br />

At the very top of the web page there’s a doctype declaration:<br />

<br />

This is used to tell the browser how to interpret the page. If you don’t have a correct doctype, the<br />

browser will immediately go into quirks mode. Be sure to get this right! I’ve never been able to learn it by<br />

heart, so I usually copy and paste it from existing pages. The good news if you’re using HTML 5 is that<br />

the doctype is simply as follows:<br />

<br />

I’m pretty sure that I’ll be able to completely memorize this one.<br />

The <br />

The section of the page contains a few important elements. First there’s the title, which sets the<br />

title of the page, and then there’s a meta element, which tells what kind of character encoding you’re<br />

using. This element is necessary for the document to be valid! I recommend using UTF-8 since it<br />

includes special characters for all languages.<br />

<br />

My first <strong>Google</strong> Map<br />

<br />

<br />

■ Tip To learn more about character encoding, which is a whole science in itself, read the article “The Absolute<br />

Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No<br />

Excuses!)” by Joel Spolsky at www.joelonsoftware.com/articles/Unicode.html.<br />

The <br />

Finally, the element contains the elements that will be visible on the web page. In this example<br />

case, you’re not going to have a lot of stuff here. But you will have a heading () and a element.<br />

The element will eventually contain the map and will have the attribute id="map". This is<br />

important, because it’s through this ID that you will target this element, both from your style sheet and<br />

from your JavaScript. You’ll learn more about this later in the chapter.<br />

28

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

Saved successfully!

Ooh no, something went wrong!