Vous êtes sur la page 1sur 7

-

Google Maps
Power Tools for
Maximizing the API

Evangelos Petroutsos

Mc
Graw
Hill
Education

New York Chicago San Francisco Athens


London Madrid Mexico City Milan
New Delhi Singapore Sydney Toronto

Contents
Acknowledgments
Introduction
Chapter 1

Chapter 2

Chapter 3

Introduction to Maps and the Google API


Building Map-Driven Applications
The Map Tiles
Cartography 101
The Mercator Projection
A Global Addressing Scheme: Parallels and Meridians
Converting Angles to Length Units
The Google Maps API
Using the Google Maps API
Summary
Designing Web Pages with Embedded Maps
The Structure of a Web Page
Adding a Map to Your Page
Is Notepad the Editor of Choice?
Map Localization
Zooming with the Mouse
The Map's Controls
Adding Markers to the Map
A Useful Template for Mapping Pages
Designing the Demo Map Page
Summary
Web Page Scripting: An Introduction to JavaScript
What Is JavaScript?
How to Test JavaScript Code
JavaScript's Basic Syntax
Variables and Data Types
Arithmetic Operations
Math Operations
Working with Text
Working with Dates
Control Flow Statements
Conditional Statements
Looping Statements

xv
xvii
1
2
2
5
6
10
12
15
15
18
19
19
24
27
28
29
30
32
34
35
40
41
41
43
45
47
48
49
51
54
56
56
59

ix

Google Maps: Power Tools for Maximizing the API

Functions
Arrays
Array Properties a n d M e t h o d s
Summary

62
65
66
70

Chapter 4

Advanced JavaScript Topics


Storing Data in Custom Objects
Creating Objects O n the Fly
Variables a n d Objects
Objects a n d M e t h o d s
Prototyping Custom Objects
Custom Objects as Collections
Event Listeners
Passing Information to the Event Listener
Removing a n Existing Listener
Closures
Summary

71
71
72
74
75
77
79
82
82
84
84
89

Chapter 5

Google Maps API: The Building Blocks of Mapping Applications


T h e Google Maps API at a Glance
T h e g o o g l e . m a p s . Map Object
M a p Initialization
Map Options
Map M e t h o d s
T h e Marker a n d InfoWindow Objects
Working with Map Events
T h e Basic M a p Events Application
Drag Events
Mouse Events
State Events
A Customized Map
A d d i n g a Context M e n u to the M a p
Designing the Context M e n u
Displaying the Context M e n u
A M o r e Elaborate Context M e n u
T h e Multiple Maps Application
Summary

91
91
92
93
94
98
100
100
101
101
103
105
106
109
110
Ill
113
115
116

Chapter 6

Windows Mapping: Embedding Maps in Desktop Applications


Why a Desktop Application
Using Google Maps with Desktop Applications
T h e WebBrowser Control
T h e Windows M a p p i n g Application
T h e Application's Architecture
Designing the Application
Building the Windows Interface
A d d i n g Custom Functions to the Script

117
118
118
119
121
121
123
126
127

Contents

Chapter 7

Chapter 8

Chapter 9

Function Return Values


Notifying the Host Application with Method Calls
The Interaction Model of the Two Components
Initializing the Map
Updating the Interface
Adding the Context Menu
Tracking User Navigation
Adding Markers to the Map
Summary
Markers: Identifying Locations on the Map
Marking Locations on the Map
Adding a New Marker
Qualifying Markers with InfoWindows
Customizing the Marker's Icon
Placing Multiple Markers on the Map
The RichMarker Control
Annotating a Map with RichMarkers
An Alternate Approach to InfoWindows
Summary
Feature Annotation: Drawing Shapes on Maps
Polylines
Polyline Construction
Polygons
Polygons with Holes
Polygon Islands
Displaying a Crosshair on the Map
Rectangles
Circles
Fixed-Size Circles
Storing Paths in MVCArrays
An Editable Polyline
Placing Symbols Along Polylines
Handling Large Paths
Summary
Interactive Drawing: The Basics of Drawing on Google Maps
Who Needs to Draw on a Map?
A Simple Web Application for Drawing on Maps
Outlining the Interaction Model
A Simple Starting Point
The Interactive Drawing Application
Handling Vertices
Handling Shapes
Customizing the Vertex Icons
Retrieving Shape Data

130
131
133
134
135
137
140
142
144
145
145
146
148
150
150
152
155
158
161
163
163
165
166
166
168
169
171
172
173
175
175
179
181
183
185
185
187
189
191
195
196
199
200
201

XI

xii

Google Maps: Power Tools for Maximizing the API

A Windows Map Drawing Application


Interacting with the Script from a .NET Application
The .NET Code
The Map Tracing Application
How to Use the Application
Summary
Chapter 10 Geodesic Calculations: The Geometry Library
A Quick Overview of the Mercator Projection
Geodesic Lines and Shapes
Defining Geodesic Paths
The Geometry Library
The g e o m e t r y , s p h e r i c a l Methods
The g e o m e t r y . p o l y Functions
Exercising the Geometry Library
Rhumb Lines
Encoded Paths
Summary
Chapter 11 The KML Data Format: Persisting Spatial Data
XML 101
XML Uses Named Delimiters
Nesting XML Elements
Qualifying Elements with Attributes
The Three XML Rules
Understanding KML
The Structure of a KML Document
Viewing KML Files on Google Maps
Tools for Preparing KML Files
Adding a KML Layer to Your Map
Handling KML Events
Organizing Placemarks in Folders
Generating KML Files
Summary
Chapter 12 Adding GIS Features to Mapping Applications
The Simple GIS Application
The Basic Features of the Application
The Desktop Version of Simple GIS
Saving the Map Annotations
Summary
Chapter 13 SQL Spatial: Backend Databases for Spatial Data
Using Tables with Spatial Features
Designing the Sample Tables
Inserting Spatial Data
Outer and Inner Polygons
Handling Data with SQL Server Management Studio

203
203
204
206
206
208
209
209
211
212
221
222
223
224
226
228
229
231
231
232
233
234
234
235
235
239
243
244
246
250
251
253
255
255
257
267
273
276
277
278
279
281
286
287

Contents

Querying Spatial Data


Calculating Distances
Line Lengths and Polygon Areas
Intersections
Joining Tables on Geo-Coordinates
Additional Spatial Features
Converting Geography Features into JSON Objects
Summary
Chapter 14 Marker Clustering: Handling Many Markers on the Map
Handling Maps with Too Many Markers
Display Markers as You Go
The MarkerClusterer Component
Summary
Chapter 15 Web Services: Updating Maps On the Fly
Web Services
Calling an Existing Web Service
Contacting the Web Service from Within Your Script
Calling XML Web Services
Processing XML Documents in JavaScript
Preparing Spatial Data for the Web
Reading the County Borders
Building a Web Service
Summary
Chapter 16 Map Annotation and Map Generation Techniques
The Process of Preparing Annotated Maps
An Alternate Approach to InfoWindows
Annotating Maps with Labels
Map Generation Techniques
Summary
Chapter 17 More Google Services: The Geocoding and Directions APIs
The Geocoding API
The Geocoding Response
The Response's Elements
Using the Geocoding API from Within JavaScript
The Directions API
Using the Directions Web Service
The Directions Request and Response
Summary
Chapter 18 Visualizing Large Datasets
Beyond Markers
Visualizing the Earthquakes
Parsing the Earthquake Data
Interacting with the Symbols

290
291
292
294
299
300
304
306
307
308
309
313
315
317
318
318
324
325
327
330
333
338
339
341
342
343
346
354
355
357
358
358
362
363
369
370
370
380
381
381
384
385
387

Xi

XJV

Google Maps: Power Tools for Maximizing the API

Heatmaps
Constructing the Heatmap
Summary
Chapter 19 Animating Items on the Map
Animating Items on a Map
Basic Animation Concepts
JavaScript Animation
The Paris Metro Animated
The Paris Metro Simple Page
Animating All Metro Lines
Summary
Chapter 20 Advanced JavaScript Animation
Scalable Vector Graphics
Creating SVG Icons
Using the SVG Icon
Animated Flights
Scaling the Flight Animation Time
Animated Heatmaps
The Animation Function
Aggregating the Rainfall Values
Index

389
390
394
395
395
397
397
399
407
413
414
415
415
416
418
418
419
424
427
429
433

Vous aimerez peut-être aussi