You are on page 1of 15

Working with Google Maps

Javascript, XML, and AJAX

By: James McAndrew

What is Google Maps?

  Google Maps is a free web mapping service.

  It offers street level maps for pedestrians, cars, and public


  It also shows terrain and photographic information.

  It has a very extendable API (Application Programming

Interface) that can be used to develop custom Google Maps
based applications.
How can developers use Google Maps

  Google Maps “Mashups” have been popular for quite some

time. Some examples of these are:
 - A Craigslist Apartment
finder / Google Maps mashup
 - A map of recent posts on the website
  Many more examples can be found here:
to-waste-away-your-day/ and all over the web
This Slide Show

  This Slide show was created to demonstrate the basic concepts

behind adding markers to a Google Maps document.
  This Slide show will not cover Javascript programming or
customization of Google Maps applications.
  It is intended to give users a better understanding of how these
mashups are created.
  Developers may want to use the example code to extend their own
maps. There are links at the end of the presentation to the full
developers site.

  HyperText Markup Language.

  The language of the World Wide Web

  Example:

  Javascript is a client side scripting language.

  It is generally run within the user’s Web Browser.

  Very similar to both C and Java, but is a distinct language

with its own syntax.

  Many dynamic websites are driven by Javascript. (e.g.

Google Maps)

  eXtensible Markup Language

  Similar to HTML
  Used to store information.
  Example:
<recipe name=“Cracker” prep_time="5 mins" cook_time="3 hours">
<title>Basic bread</title>
<ingredient amount=“1” unit=“cup”>Flour</ingredient>
<ingredient amount=“1” unit=“cup”>Water</ingredient>
<step>Mix ingredients together.</step>
<step>Bake in the oven at 180°C for 30 minutes.</step>

  Asynchronous JavaScript and XML

  Used to dynamically load XML information into a HTML

window using JavaScript.

  Ajax is not a programming language, the term is used to

describe the use of XMLHttpRequest or similar objects.

  XMLHttpRequest is the main object we use in JavaScript to

load an XML document.

  Google Maps provides an interface to load XML that uses

XMLHttpRequest, but does not require the programmer to
directly manipulate the XMLHttpRequest object.
Google Maps API

  Google created the Google Maps API to facilitate developers integrating

Google Maps into their web sites with their own data points. It is a free
service, which currently does not contain ads, but Google states in their terms
of use that they reserve the right to display ads in the future.

  By using the Google Maps API it is possible to embed the full Google Maps
on an external web site. Developers are required to request an API Key, which
is bound to the web site and directory entered when creating the key. Creating
your own map interface involves adding the Google JavaScript code to your
page, and then using Javascript functions to add points to the map.
  (From Wikipedia)
Requesting a Google Maps API Key


  Requires a web server to run your object.

Creating your XML Document


<marker name="Placemark 1" lat="40.191037"

lng="-75.199484" note=”Lansdale, PA" />

<marker name="Placemark 2" lat="40" lng="-75"

note="Riverside, NJ" />

Google Maps HTML
Page 1
Google Maps HTML
Page 2
More information:

  Google’s API How-To


  Google Maps API Blog


  My Example: