Websites like MapQuest and Google Maps have transformed the way we think about maps. But these services do more than offer driving directions—they provide APIs that web developers can use to build highly customized map-based applications.
In Map Scripting 101, author Adam DuVander delivers 73 immediately useful scripts that will show you how to create interactive maps and mashups. You'll build tools like a local concert tracker, a real-time weather map, a Twitter friend-finder, an annotated map of Central Park, and much more. And because the book is based on the cross-platform Mapstraction JavaScript library, everything you create will be able to use nearly any mapping service, including OpenStreetMap, MapQuest, Google, Yahoo!, and Bing.
You'll also learn how to:
Create, embed, and manipulate basic maps by setting zoom levels and map boundaries
Show, hide, and filter location markers and info-bubbles
Customize your maps for visitors based on their location
Use common data formats like GPS XML, Google Earth's KML, and GeoRSS
Create graphical overlays on maps to better analyze data and trends
Use freely available geodata from websites like Yelp and Upcoming—and public domain geodata from the US government
Map Scripting 101 is perfect for any web developer getting started with map scripting, whether you want to track earthquakes around the world, or just mark the best coffee shops in Dubuque.
Chapter 1 MAPPING BASICS
The Mapping APIs: Google, Yahoo!, and Mapstraction
Describe a Point on the Earth
Create Your First Map
Find the Underlying Map Tiles
Change the Map Size
Add Zoom and Other Controls
Set Zoom Level
Set Map Type
Recenter the Map
Retrieve the Center of the Map
Find Point Where User Clicked
Chapter 2 PLOTTING MARKERS AND MESSAGE BOXES
#1: Add a Marker to Your Map
#2: Remove or Hide a Marker
#3: Show a Message Box When Your Marker Is Clicked
#4: Show and Hide Message Boxes Without Clicking the Marker
#5: Create a Custom Icon Marker
#6: Create Numbered Markers
#7: Loop Through All Markers
#8: Determine the Correct Zoom Level to Use Based on Markers
#9: Filter Out Certain Markers
#10: Remove or Hide All Markers
#11: Handle Clusters of Markers
Chapter 3 GEOCODING
How Do Geocoders Work?
JavaScript vs. HTTP Geocoding
#12: Geocode with JavaScript
#13: Geocode with an HTTP Web Service
#14: Reverse Geocoding: Get an Address from a Point
#15: Get Postal Code Coordinates
Chapter 4 LAYER IT ON
#16: Draw Lines on a Map
#17: Draw Shapes on a Map
#18: Add Circles to Show Search Radius
#19: Draw a Rectangle to Declare an Area
#20: Draw Lines Along Clicks
#21: Color States/Countries on a Map
#22: Add Custom Controls
#23: Create Your Own Zoom Interface
#24: Plot Image Thumbnails on a Map
#25: Overlay an Image on a Map
#26: Use Custom Tiles
Chapter 5 HANDLE MAP EVENTS
Mapstraction's Event Model
#27: The User Clicks the Map
#28: The User Drags the Map
#29: The Zoom Level Changes
#30: A Marker Is Added to or Removed from the Map
#31: A Polyline Is Added to or Removed from the Map
#32: The User Opens or Closes a Message Box
#33: The User Clicks a Marker
#34: Return to the Center When the Message Box Is Closed
#35: The User Moves the Map Outside Preset Bounds
Chapter 6 EXPLORE PROXIMITY
#36: Calculate Distance Between Two Points
#37: Find True Distance with Routing
#38: Create Driving Directions
#39: Determine Closest Marker
#40: Find a Point Along a Line
#41: Plot Local Results on a Map
#42: Retrieve Local Results with HTTP
#43: Check Whether a Point Is Within a Bounding Box
#44: Get a Random Point in a Bounding Box
#45: Check Whether a Point Is Within a Shape
#46: Get Nearest Locations from Your Own Database
Chapter 7 USER LOCATION
#47: Ask Users Where They Are
#48: Get Location Using JavaScript
#49: Use Fire Eagle to Get Location
#50: Get Location by IP
#51: Roll Your Own IP Database
Chapter 8 DATA FORMATS
#52: Use XML
#53: Use JSON
#54: Use GeoRSS
#55: Use KML
#56: Use GPX
#57: Convert from XML to JSON
#58: Filter, Merge, and Sort Data with Yahoo Pipes!
Adam DuVander writes about geolocation, web development, and APIs for Programmable Web and WebMonkey, Wired.com's web developer resource. He has presented his work at SXSW and O'Reilly's Where 2.0 conference. He lives at 45° 33' 25" N, 122° 31' 55" W (otherwise known as Portland, Oregon).