Enviar pesquisa
Carregar
Geolocation
•
0 gostou
•
481 visualizações
Tom Fan
Seguir
Tecnologia
Negócios
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 14
Recomendados
Storage
Storage
Tom Fan
Semantics
Semantics
Tom Fan
Web sockets
Web sockets
Tom Fan
File api
File api
Tom Fan
HTML5 Web workers
HTML5 Web workers
Tom Fan
Multimedia
Multimedia
Tom Fan
Html5 history
Html5 history
Tom Fan
Deviceaccess
Deviceaccess
Tom Fan
Recomendados
Storage
Storage
Tom Fan
Semantics
Semantics
Tom Fan
Web sockets
Web sockets
Tom Fan
File api
File api
Tom Fan
HTML5 Web workers
HTML5 Web workers
Tom Fan
Multimedia
Multimedia
Tom Fan
Html5 history
Html5 history
Tom Fan
Deviceaccess
Deviceaccess
Tom Fan
Webstorage
Webstorage
Tom Fan
Css3
Css3
Tom Fan
Intro to-html5
Intro to-html5
Tom Fan
PhoneGap 通信原理和插件系统
PhoneGap 通信原理和插件系统
Tom Fan
AT&T 的 HTML5 策略和应用现状
AT&T 的 HTML5 策略和应用现状
Tom Fan
Podularityftw 130528020402-phpapp02
Podularityftw 130528020402-phpapp02
Wooga
Portfolio Performance: GE Global Research Cracks the Code with Clarizen
Portfolio Performance: GE Global Research Cracks the Code with Clarizen
Clarizen
Searching For New Direct Response Marketing Channels
Searching For New Direct Response Marketing Channels
Chris Zaharias
Trasparenze interpretazione comunicazione
Trasparenze interpretazione comunicazione
Giuseppe Cistaro
The top 20 luxurious & expensive hotels in the world
The top 20 luxurious & expensive hotels in the world
AlexLee01
Cartner on Environmental Heat Stress
Cartner on Environmental Heat Stress
SMACC Conference
Paeds plenary-mc caskill
Paeds plenary-mc caskill
SMACC Conference
Mary McCaskill: Neonatal Nightmares
Mary McCaskill: Neonatal Nightmares
SMACC Conference
Atention
Atention
Giuseppe Cistaro
Baby Gadgets
Baby Gadgets
Mihex
Deep dive
Deep dive
antivladinforum
Incite: Marketing
Incite: Marketing
Incite Marketing and Communications
Incite: Communications
Incite: Communications
Incite Marketing and Communications
Html5 最重要的部分
Html5 最重要的部分
Tom Fan
PhoneGap 2.0 开发
PhoneGap 2.0 开发
Tom Fan
Android 平台 HTML5 应用开发
Android 平台 HTML5 应用开发
Tom Fan
HTML5 生态系统和应用架构模型
HTML5 生态系统和应用架构模型
Tom Fan
Mais conteúdo relacionado
Destaque
Webstorage
Webstorage
Tom Fan
Css3
Css3
Tom Fan
Intro to-html5
Intro to-html5
Tom Fan
PhoneGap 通信原理和插件系统
PhoneGap 通信原理和插件系统
Tom Fan
AT&T 的 HTML5 策略和应用现状
AT&T 的 HTML5 策略和应用现状
Tom Fan
Podularityftw 130528020402-phpapp02
Podularityftw 130528020402-phpapp02
Wooga
Portfolio Performance: GE Global Research Cracks the Code with Clarizen
Portfolio Performance: GE Global Research Cracks the Code with Clarizen
Clarizen
Searching For New Direct Response Marketing Channels
Searching For New Direct Response Marketing Channels
Chris Zaharias
Trasparenze interpretazione comunicazione
Trasparenze interpretazione comunicazione
Giuseppe Cistaro
The top 20 luxurious & expensive hotels in the world
The top 20 luxurious & expensive hotels in the world
AlexLee01
Cartner on Environmental Heat Stress
Cartner on Environmental Heat Stress
SMACC Conference
Paeds plenary-mc caskill
Paeds plenary-mc caskill
SMACC Conference
Mary McCaskill: Neonatal Nightmares
Mary McCaskill: Neonatal Nightmares
SMACC Conference
Atention
Atention
Giuseppe Cistaro
Baby Gadgets
Baby Gadgets
Mihex
Deep dive
Deep dive
antivladinforum
Incite: Marketing
Incite: Marketing
Incite Marketing and Communications
Incite: Communications
Incite: Communications
Incite Marketing and Communications
Destaque
(18)
Webstorage
Webstorage
Css3
Css3
Intro to-html5
Intro to-html5
PhoneGap 通信原理和插件系统
PhoneGap 通信原理和插件系统
AT&T 的 HTML5 策略和应用现状
AT&T 的 HTML5 策略和应用现状
Podularityftw 130528020402-phpapp02
Podularityftw 130528020402-phpapp02
Portfolio Performance: GE Global Research Cracks the Code with Clarizen
Portfolio Performance: GE Global Research Cracks the Code with Clarizen
Searching For New Direct Response Marketing Channels
Searching For New Direct Response Marketing Channels
Trasparenze interpretazione comunicazione
Trasparenze interpretazione comunicazione
The top 20 luxurious & expensive hotels in the world
The top 20 luxurious & expensive hotels in the world
Cartner on Environmental Heat Stress
Cartner on Environmental Heat Stress
Paeds plenary-mc caskill
Paeds plenary-mc caskill
Mary McCaskill: Neonatal Nightmares
Mary McCaskill: Neonatal Nightmares
Atention
Atention
Baby Gadgets
Baby Gadgets
Deep dive
Deep dive
Incite: Marketing
Incite: Marketing
Incite: Communications
Incite: Communications
Mais de Tom Fan
Html5 最重要的部分
Html5 最重要的部分
Tom Fan
PhoneGap 2.0 开发
PhoneGap 2.0 开发
Tom Fan
Android 平台 HTML5 应用开发
Android 平台 HTML5 应用开发
Tom Fan
HTML5 生态系统和应用架构模型
HTML5 生态系统和应用架构模型
Tom Fan
18 NSUserDefaults
18 NSUserDefaults
Tom Fan
17 Localization
17 Localization
Tom Fan
16 CoreData
16 CoreData
Tom Fan
15 Subclassing UITableViewCell
15 Subclassing UITableViewCell
Tom Fan
14 Saving Loading and Application States
14 Saving Loading and Application States
Tom Fan
13 UIPopoverController and Modal View Controller
13 UIPopoverController and Modal View Controller
Tom Fan
12 Camera
12 Camera
Tom Fan
11 UINavigationController
11 UINavigationController
Tom Fan
10 Editing UITableView
10 Editing UITableView
Tom Fan
09 UITableView and UITableViewController
09 UITableView and UITableViewController
Tom Fan
08 Notification and Rotation
08 Notification and Rotation
Tom Fan
07 View Controllers
07 View Controllers
Tom Fan
06 Subclassing UIView and UIScrollView
06 Subclassing UIView and UIScrollView
Tom Fan
Mais de Tom Fan
(17)
Html5 最重要的部分
Html5 最重要的部分
PhoneGap 2.0 开发
PhoneGap 2.0 开发
Android 平台 HTML5 应用开发
Android 平台 HTML5 应用开发
HTML5 生态系统和应用架构模型
HTML5 生态系统和应用架构模型
18 NSUserDefaults
18 NSUserDefaults
17 Localization
17 Localization
16 CoreData
16 CoreData
15 Subclassing UITableViewCell
15 Subclassing UITableViewCell
14 Saving Loading and Application States
14 Saving Loading and Application States
13 UIPopoverController and Modal View Controller
13 UIPopoverController and Modal View Controller
12 Camera
12 Camera
11 UINavigationController
11 UINavigationController
10 Editing UITableView
10 Editing UITableView
09 UITableView and UITableViewController
09 UITableView and UITableViewController
08 Notification and Rotation
08 Notification and Rotation
07 View Controllers
07 View Controllers
06 Subclassing UIView and UIScrollView
06 Subclassing UIView and UIScrollView
Geolocation
1.
HTML5 开发 Web,MobileWeb &
Apps 范圣刚 安博中程在线
2.
Geolocation 定位和跟踪
3.
介绍 安博中程在线 Geolocation工作原理 Geolocation API Example 扩展阅读 · · getCurrentPosition方法 Geolocation数据 Handling Errors PositionOptions对象 watchPosition()方法和clearWatch()方法 - - - - - · · 3/14
4.
Geolocation工作原理 识别地理位置的主要方法: 安博中程在线 通过IP地址 利用基站获取手机网络的接入位置 通过利用卫星定位获得经纬度信息的GPS设备 · · · 4/14
5.
Geolocation API 可以获得用户所在地理位置的经纬度信息 调用Geolocation API从全局navigator对象的geolocation属性开始: navigator.geolocation 安博中程在线 <scripttype='text/javascript'> //最简单的使用方式:没有做任何的检测,错误处理,也没有选项参数 functionfind_my_location(){ navigator.geolocation.getCurrentPosition(show_map); } </script> JAVASCRIPT 5/14
6.
Geolocation API 检测浏览器是否支持地理位置API 方法1: 检测检测
全局对象navigator是否具有geolocation属性 方法2: 使用Modernizr提供的方法 检测检测 安博中程在线 <script type='text/javascript'> function supports_geolocation() { return !!navigator.geolocation; } </script> JAVASCRIPT <script type='text/javascript'> function find_my_location() { if (Modernizr.geolocation) { navigator.geolocation.getCurrentPosition(show_map); } else { // 浏览器没有提供原生支持,使用回退方案 } } </script> JAVASCRIPT 6/14
7.
Geolocation API getCurrentPosition() 使用getCurrentPosition()方法 获取当前位置信息获取当前位置信息
. 安博中程在线 <script type='text/javascript'> function find_my_location() { if (Modernizr.geolocation) { navigator.geolocation.getCurrentPosition(show_map); } else { // 其他方案 } } function show_map(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; alert('Lat: ' + latitude + ' Lon: ' + longitude); } </script> JAVASCRIPT 7/14
8.
Position数据 成功的回调函数的参数是一个Position对象,包括coords和timestamp两个属性。 属性 类型 备注 coords.latitude
double 纬度(度) coords.longitude double 经度(度) coords.accuracy double 精度(米) coords.altitude double或null 海拔(米) coords.altitudeAccuracy double或null 海拔精度(米) coords.heading double或null 度(顺时针,以正北为基准) coords.speed double或null 米/秒 timestamp DOMTimeStamp 可以转成Date对象 安博中程在线 8/14
9.
Handling Errors getCurrentPosition()的第二个参数(可选)——容错处理的回调函数: 在获取地理位置过程中有任何错误,都会调用该回调函数,并且会传入一个PositionError对象作为参数。 安博中程在线 <script type='text/javascript'> function
find_my_location() { if (Modernizr.geolocation) { navigator.geolocation.getCurrentPosition(show_map, handle_error); } else { // 其他方案 } } function handle_error(err) { if (err.code == 1) { // 用户说不! } } </script> JAVASCRIPT 9/14
10.
PositionError对象 属性 类型 备注 code
short 可枚举 message DOMString 与终端用户无关 其中code属性具有以下属性值: 安博中程在线 PERMISSION_DENIED(1): 用户不同意被获取位置信息。 POSITION_UNAVAILABLE(2): 网络不可用或者无法连接到获取位置信息的卫星。 TIMEOUT(3): 网络可用但是花了太长时间的计算用户的位置上。 UNKNOWN_ERROR(0): 发生其他未知错误。 · · · · 10/14
11.
PositionOptions对象 两种定位方式和缓存的位置信息 属性 类型 默认值
备注 enableHighAccuracy boolean false 设成true可能会使得获取位置的速度变慢 timeout long 没有默认值 单位:毫秒 maximumAge long 0 单位:毫秒 安博中程在线 11/14
12.
Example 获得经纬度信息并在地图上显示 显示位置显示位置 安博中程在线 navigator.geolocation.getCurrentPosition(function(position) { var latLng
= new google.maps.LatLng( position.coords.latitude, position.coords.longitude); var marker = new google.maps.Marker({position: latLng, map: map}); map.setCenter(latLng); } JAVASCRIPT 12/14
13.
扩展阅读 安博中程在线 W3C地理位置 API geo.js, 地理位置的JS
Framework。依照W3C地理位置 API规范封装了底层系统特定的实现。 · · 13/14
14.
<Thank you!> 微博 @范圣刚 博客
www.tfan.org github github.com/princetoad