18
Google Maps API Dr. Harry Chen CMSC 491S/691S March 26, 2008

Google Maps API

  • Upload
    hchen1

  • View
    13

  • Download
    2

Embed Size (px)

DESCRIPTION

http://tinyurl.com/2flvsk

Citation preview

Page 1: Google Maps API

Google Maps API

Dr. Harry Chen

CMSC 491S/691S

March 26, 2008

Page 2: Google Maps API

Agenda

“Fire hose” course on Google Maps API HelloWorld example Basic UI components Loading data

Assignment #3

Page 3: Google Maps API

HelloWorld

What happened here?

Page 4: Google Maps API

“View Page Source”

Google Maps API Key (required)

Page 5: Google Maps API

What’s involved

Define a <div/> tag where the map is to be created (“map_canvas”)

Load GMaps API in <head/>

Register the “initialize()” function to be called when the event “onload” is fired

Page 6: Google Maps API

The initialize() function

Checks if your browser is supported by the GMaps API

Creates a GMap2 object and initializes the map UI inside the DOM element ID “map_canvas”

Centers the map to a given lat/lng value

Page 7: Google Maps API

Key Map Controls

Control: Zoom

Control: Map Type

Control: Overview

http://code.google.com/apis/maps/documentation/controls.html#Controls_overview

Control: Pan

Page 8: Google Maps API

Control Code Example

Page 9: Google Maps API

GMarker

Markers : Use GMarker to create markers

Page 10: Google Maps API

Customize GMarker

Use your own marker icon

Use a smaller marker icon

http://code.google.com/apis/maps/documentation/overlays.html#Markers

Page 11: Google Maps API

OpenInfoWindowHtml

This func creates GMarker

Page 12: Google Maps API

On Creating GMarker

We have seen how to create GMarkers on a map, and our data is hardwired

Unless your map data is static, you will need to load location data dynamically

How to load data?

Page 13: Google Maps API

On loading data

Option 1: Define data in the <head/> of your map page

Option 2: Read from a GeoRSS fileOption 3: Read from a KML fileOption 4: Read from a custom XML file

Page 14: Google Maps API

Read from a GeoRSS/KML file

What’s GeoRSS? What’s KML?

So easy!

Page 15: Google Maps API

Read from a custom XML file

Some app only produce proprietary data in XML

In order to render this data on a map, you must read and parse XML

Sounds complicated?

Page 16: Google Maps API

Read from a custom XML

GDownloadUrl: Built-in for downloading any data from a remote URL

GXml: XML parser!

Page 17: Google Maps API

Resources

Google Maps’ Developer Guide http://code.google.com/apis/maps/documentation/index.html

Mike Williams’s Google Maps API Tutorial http://econym.googlepages.com/index.htm

Page 18: Google Maps API

Assignment #3