25.02.2013 Views

Peter Lubbers - Pro HTML 5 Programming

Pro HTML 5 Programming

Pro HTML 5 Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

114<br />

CHAPTER 4 ■ USING THE <strong>HTML</strong>5 GEOLOCATION API<br />

Listing 4-18. Passing a position to the Google Map API<br />

// Create a Google Map… see Google API for more detail<br />

var map = new google.maps.Map(document.getElementById("map"));<br />

function updateLocation(position) {<br />

//pass the position to the Google Map and center it<br />

map.setCenter(new google.maps.LatLng(position.coords.latitude,<br />

position.coords.longitude);<br />

}<br />

navigator.geolocation.getCurrentPosition(updateLocation,<br />

handleLocationError);<br />

Summary<br />

This chapter discussed <strong>HTML</strong>5 Geolocation. You learned the <strong>HTML</strong>5 Geolocation location<br />

information—latitude, longitude, and other attributes—and where they can come from. You also<br />

learned about the privacy concerns that accompany <strong>HTML</strong>5 Geolocation and you’ve seen how the<br />

<strong>HTML</strong>5 Geolocation APIs can be used to create compelling, location–aware web applications.<br />

In the next chapter, we’ll demonstrate how <strong>HTML</strong>5 lets you communicate between tabs and<br />

windows as well as between pages and servers with different domains.

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

Saved successfully!

Ooh no, something went wrong!