没有合适的资源?快使用搜索试试~ 我知道了~
首页Google.Maps.API.V2.pdf
资源详情
资源评论
资源推荐
Google Maps API, V2
Adding Where To Your Applications
Scott Davis
The Pragmatic Bookshelf
Raleigh, North Carolina Dallas, Texas
Many of the designations used by manufacturers and sellers to distin-
guish their products are claimed as trademarks. Where those designations
appear in this book, and The Pragmatic Programmers, LLC was aware of
a trademark claim, the designations have been printed in init i al capital
letters or i n all capit als. The Pragmatic Starter Kit, The Pragmatic Pro-
grammer, Pragmatic Programming, Pragmatic Bookshelf and th e linking g
device are trademarks of The Pragmatic Programmers, LLC.
Useful Friday Links
• Source code from this book and
other resources.
• Free updat es to this PDF
• Errata and suggestions. To report
a
n erratum on a page, click the
link in the footer.
Every precaution was taken in the preparation of this book. However,
the publisher assumes n o responsibility for errors or omissions, or for
damages th at may result from the use of information (i ncluding program
listings) contained herein.
To see what we’re up to, please visit us at
http://www.pragmaticprogrammer.com
Copyright
©
2
006 The Pragmatic Programmers LLC.
All rights reserved.
This PDF publication is intended for the personal use of the individual
whose name appears at the bottom of each page. This publication may not
be disseminated to others by any means without the prior consent of the
publisher. In particular, the publication must not be made available on
the Internet (via a web server, file sharing network, or any other means).
Produced in the United States of America.
Bo
o
ks
he
lf
Pr
a
g m
ati
c
Lovingly created by g erbil #32 on 2006-5-18
rida
y s
Contents
1 Google Maps 1
1.1 A Brief History . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Here’s the Game Plan . . . . . . . . . . . . . . . . . . 3
2 For Those in a Hurry... 5
2.1 The Simple Map . . . . . . . . . . . . . . . . . . . . . 5
2.2 Adding navigation components . . . . . . . . . . . . . 7
2.3 Setting the initial map type . . . . . . . . . . . . . . . 8
2.4 Creating a Point and an Info Window . . . . . . . . . 10
3 The Excruciating Details 12
3.1 Core Objects . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 Map Controls . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 User Data . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.4 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.5 AJAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4 Core Objects 14
4.1 GMap2 . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.2 GLatLng . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.3 GLatLngBounds . . . . . . . . . . . . . . . . . . . . . 16
5 Map Control Objects 20
5.1 Panning . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.2 Zooming . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.3 Changing t he Map Type . . . . . . . . . . . . . . . . . 22
5.4 GOverviewMap . . . . . . . . . . . . . . . . . . . . . . 23
5.5 Putting it all together . . . . . . . . . . . . . . . . . . 23
rida
y s
CONTENTS CONTENTS iv
6 User Data Objects 25
6.1 GMarker . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.2 GIcon . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.3 Info Windows . . . . . . . . . . . . . . . . . . . . . . . 31
6.4 GPolyline . . . . . . . . . . . . . . . . . . . . . . . . . 35
7 Events 39
7.1 GEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
7.2 GBrowserIsCompatible . . . . . . . . . . . . . . . . . 42
7.3 GMap Events . . . . . . . . . . . . . . . . . . . . . . . 42
7.4 Event Ha ndlers . . . . . . . . . . . . . . . . . . . . . . 44
7.5 GMarker Events . . . . . . . . . . . . . . . . . . . . . 45
7.6 Simple Examples . . . . . . . . . . . . . . . . . . . . . 46
7.7 A Real-World Example . . . . . . . . . . . . . . . . . . 48
8 AJAX 59
8.1 DHTML and AJAX . . . . . . . . . . . . . . . . . . . . 59
8.2 GXmlHttp . . . . . . . . . . . . . . . . . . . . . . . . . 60
8.3 Geocoder Web Services . . . . . . . . . . . . . . . . . 61
8.4 Revisiting the Real-World Example . . . . . . . . . . 64
9 Where do we go from here? 69
Report erratum
rida
y s
Chapter 1
Google Maps
The Google Ma ps API, version 2 (http://www.google.com/apis/maps/)
is a great way to dip your toe into the w o rld of web mapping. You
don’t have to w o rry about finding and managing your own data,
installing and configuring your own server, or creating your own
cross-browser AJAX mapping framework from scratch. It’s a pro-
grammer’s dream—with a little bit of JavaScript and a few lati-
tude/longitude points, you are off to the races.
It is, however, aimed squarely at programmers. Yo u will be neck-
deep in JavaScript from the get-go. If all you want is a simple map
without having to program it yourself, there is an easier way: Yahoo!
Maps (htt p://developer.yahoo.net/ maps/) pro vides a simple service
t
hat allows you to pass in an XML list of points and get a fully
rendered map out on the other side. You can give it either lat/long
points or plain old street addresses. Yahoo! handles everything
for you—creating the points on the map, handling pop-up “bubbles”
over your data points, the whole nine yar ds. You can pass in custom
icons, html links, and descriptive text for each item in t he XML. You
get quite a bit of flexibility for a canned application.
The Google Maps A PI gives you the same functionality as Yahoo!
Maps—pop-up bubbles (called Info Windows in Go o gle-speak), cus-
tom icons, and so on—but you have to be much more deeply involved
in the implementation. After all, Google Maps is an API, not a
finished a pplication. You get all of the pieces, but there is “some
assembly required.”
The upside is that you have much more control of your applica-
tion. You have an event model that you can tap into—you can
剩余74页未读,继续阅读
letian1989615
- 粉丝: 49
- 资源: 35
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 27页智慧街道信息化建设综合解决方案.pptx
- 计算机二级Ms-Office选择题汇总.doc
- 单链表的插入和删除实验报告 (2).docx
- 单链表的插入和删除实验报告.pdf
- 物联网智能终端项目设备管理方案.pdf
- 如何打造品牌的模式.doc
- 样式控制与页面布局.pdf
- 武汉理工Java实验报告(二).docx
- 2021线上新品消费趋势报告.pdf
- 第3章 Matlab中的矩阵及其运算.docx
- 基于Web的人力资源管理系统的必要性和可行性.doc
- 基于一阶倒立摆的matlab仿真实验.doc
- 速运公司物流管理模式研究教材
- 大数据与管理.pptx
- 单片机课程设计之步进电机.doc
- 大数据与数据挖掘.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论3