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.

C H A P T E R 3<br />

■ ■ ■<br />

Creating Your First Map<br />

A <strong>Google</strong> map resides in a web page. So, the first thing you need to do is to set up that page. This<br />

includes creating an HTML page and a style sheet for it. Once you have everything set up, you can insert<br />

the actual map. In this chapter, I will guide you through all the necessary steps to create your very first<br />

<strong>Google</strong> <strong>Maps</strong> page.<br />

Setting the Scene<br />

Before you start creating a map, you need to set up the web page for it. This includes creating an HTML<br />

file and a style sheet.<br />

The HTML Page<br />

The core of every web page is the HTML file. It’s important to code it properly since it forms the<br />

foundation for everything else. Without a solid foundation, the stuff you build upon it will easily break.<br />

Web browsers are very forgiving and will often render a page correctly even if the HTML is<br />

slightly faulty. I do, however, recommend that you make sure the HTML is coded properly, for a number<br />

of reasons:<br />

• Debugging<br />

If you don’t have the HTML right, strange errors may occur in your CSS or<br />

JavaScript that are really hard to find. Both the CSS and a lot of the JavaScript code<br />

relies on the HTML being correct, so to make it easier for yourself, make sure that<br />

your HTML is correct by validating it frequently. This will save you a lot of time<br />

and grief.<br />

• Performance<br />

In addition, correct HTML code renders faster than incorrect HTML. If done<br />

properly, the browser will interpret the HTML in strict mode, in which it assumes<br />

that you know what you are doing. Incorrectly done, and it will switch to quirks<br />

mode, in which it’s a lot more forgiving in its interpretation of the code. This<br />

means that you can get away with sloppy code, but since the browser has to guess<br />

what you mean, the page takes longer to render.<br />

23

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

Saved successfully!

Ooh no, something went wrong!