- 浏览: 796888 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (651)
- Java (39)
- Java 初学者小问题 (66)
- 设计模式 (7)
- 项目管理 (3)
- 数据库 (1)
- 算法 (2)
- Java practices (6)
- Effective Java2读书笔记 (78)
- Linux (2)
- programming ruby 读书笔记 (5)
- Core Java Ninth Edition Volume I 读书笔记 (15)
- Pro Git 读书笔记 (12)
- Git (3)
- Maven in Action 读书笔记 (20)
- Web (12)
- 非技术类书籍 (11)
- 电影 (40)
- Web Cache (1)
- jquery (0)
- 历史 (4)
- Dive Into HTML5 读书笔记 (13)
- 三国演义小学毕业考 (79)
- 高效能人士的7个习惯 读书笔记 (12)
- Java Performance 读书笔记 (3)
- Protocol Buffer 学习笔记 (6)
- Mongo DB 学习笔记 (7)
- Morphia 学习笔记 (7)
- Algorithms -- Princeton 学习笔记 (13)
- String研究 (10)
- Hadoop: The Definitive Guide 读书笔记 (3)
- Java与模式读书笔记 (5)
- Date研究 (3)
- The Roman Empire 听课笔记 (4)
- Algorithms -- Standford 学习笔记 (16)
- Core Java Ninth Edition Volume II 读书笔记 (9)
- Thinking in Java 4th Edition 读书笔记 (21)
- Node : Up and Running 学习笔记 (5)
- Eloquent Javascript (8)
- Smashing Node.js 读书笔记 (1)
- Algorithms II -- Standford 学习笔记 (19)
- Algorithm II -- Princeton 学习笔记 (14)
- 网络安全 (2)
- Javascript (4)
- 正则表达式 (1)
- JAVA 7/8 (15)
- JVM (10)
- NodeJS (1)
- 鸟哥的linux私房菜读书笔记 (14)
- Web Service (1)
- The art of programming (9)
- Introduction to Algorithm 读书笔记 (4)
- Java 源码阅读 (0)
- Spring in Action 读书笔记 (2)
- Java Network Programming 读书笔记 (2)
最新评论
-
心存高远:
谢谢作者分享,刚好看到这里不太明白,现在茅塞顿开。不过runt ...
关于 Maven的传递依赖的理解 -
sxlkk:
851228082 写道甚至在某次技术会议现场遇到《Maven ...
关于 Maven的传递依赖的理解 -
851228082:
851228082 写道a----compile----b-- ...
第五章 坐标和依赖 -
851228082:
a----compile----b-----provided- ...
第五章 坐标和依赖 -
851228082:
甚至在某次技术会议现场遇到《Maven in action》的 ...
关于 Maven的传递依赖的理解
1. Geolocation is the art of figuring out where you are in the world and (optionally) sharing that information with people you trust. There is more than one way to figure out where you are — your IP address, your wireless network connection, which cell tower your phone is talking to, or dedicated GPS hardware that calculates latitude and longitude from information sent by satellites in the sky.
2. User Agents must not send location information to Web sites without the express permission of the user.
3. The simplest use of the geolocation API looks like this:
function get_location() { navigator.geolocation.getCurrentPosition(show_map); }
The call to getCurrentPosition() will return immediately, but that doesn’t mean that you have access to the user’s location. The first time you are guaranteed to have location information is in the callback function. The callback function looks like this:
function show_map(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; // let's show a map or do something interesting! }
4. The callback function will be called with a single parameter, an object with two properties: coords and timestamp . The timestamp is just that, the date and time when the location was calculated. The coords object has properties like latitude and longitude which are exactly what they sound like: the user’s physical location in the world.
Only three of the properties are guaranteed to be there (coords.latitude , coords.longitude , and coords.accuracy ). The rest might come back null , depending on the capabilities of your device and the backend positioning server that it talks to. The heading and speed properties are calculated based on the user’s previous position, if possible.
5. You can pass a second argument to the getCurrentPosition() function which is an error handling callback function. If anything goes wrong, your error callback function will be called with a PositionError object which has a code and message property. The code property will be one of :
a) PERMISSION_DENIED (1) if the user denies your access to their location.
b) POSITION_UNAVAILABLE (2) if the network is down or the positioning satellites can’t be contacted.
c) TIMEOUT (3) if the network is up but it takes too long to calculate the user’s position.
6. The getCurrentPosition() function has an optional third argument, a PositionOptions object . There are three properties you can set in a PositionOptions object: enableHighAccuracy , timeout and maximumAge . All the properties are optional. You can set any or all or none of them. The timer doesn’t start counting down until after the user gives permission to even try to calculate their position. You’re not timing the user; you’re timing the network. The maximumAge property allows the device to answer immediately with a cached position calculated whthin maximumAge milliseconds before.
7. The watchPosition() function has the same structure as getCurrentPosition() . It takes two callback functions, a required one for success and an optional one for error conditions, and it can also take an optional PositionOptions object that has all the same properties. The difference is that your callback function will be called every time the user’s location changes. The watchPosition() function itself returns a number. You should probably store this number somewhere. If you ever want to stop watching the user’s location change, you can call the clearWatch() method and pass it this number, and the device will stop calling your callback function.
8. Gears is an open source browser plugin from Google. It provides features for older browsers. One of the features that Gears provides is a geolocation API . It’s not quite the same as the W3C geolocation API , but it serves the same purpose.
9. geo.js is an open source, MIT -licensed JavaScript library that smooths over the differences between the W3C geolocation API , the Gears API , and the API s provided by mobile platforms. To use it, you’ll need to add two <script> elements at the bottom of your page:
<script src="gears_init.js"></script> <script src="geo.js"></script>
First, you need to explicitly call an init() function. The init() function returns true if a supported geolocation API is available. To actually find your location, you need to call the getCurrentPosition() function:
if (geo_position_js.init()) { geo_position_js.getCurrentPosition(geo_success, geo_error); }
geo.js does not currently support the watchPosition() function.
发表评论
-
《Dive into HTML5》 读后感
2012-06-20 07:57 1514读这本书的起因是参加了2012年的Qcon,对其中某个 ... -
Manipulating History for Fun & Profit
2012-06-20 07:29 10581. The HTML5 history AP ... -
“Distributed,”“Extensibility,”& Other Fancy Words
2012-06-15 15:54 8961. Microdata annotates t ... -
A Form of Madness
2012-06-11 10:41 9721. Placeholder text is d ... -
Let’s Take This Offline
2012-06-09 23:32 9401. An offline web app ... -
A Place To Put Your Stuff
2012-06-09 17:55 9371. Cookies have three po ... -
Video in a Flash (Without That Other Thing)
2012-06-08 15:46 11241. HTML5 defines a standard wa ... -
Let’s Call It A Draw(ing Surface)
2012-06-06 17:19 11921. HTML 5 defines the &l ... -
What Does It All Mean?
2012-06-03 19:23 10861. In Activating Browse ... -
Detecting HTML5 Features
2012-05-24 19:05 10781. There are four basic ... -
A Quite Biased History of HTML5
2012-05-23 20:02 10881. “content type” or “MIM ... -
Introduction: Five Things You Should Know About HTML5
2012-05-22 15:23 10131. HTML5 is a collectio ...
相关推荐
标题 "MATLAB.rar_You Are Here" 暗示了这是一个包含MATLAB相关代码和资源的压缩包。MATLAB(Matrix Laboratory)是一款广泛应用于工程计算、数据分析、算法开发和系统建模的高级编程环境。本压缩包可能包含了多个...
This book is aimed at new and experienced engineers, technology managers, and senior technicians who want to enrich their understanding of the image formation physics of a lithographic system....
【You Are Here-crx插件】是一款专为英文用户设计的浏览器扩展程序,它主要针对美国用户群体。这款插件的核心功能是帮助用户更好地管理和跟踪他们在网络上的浏览历史和当前活动,让用户的在线体验更加个性化和高效。...
Query is here to free you from these dull, repetitive tasks and give you time to concentrate on what’s important: analyzing your data and gaining insights from it. Even better, Power Query is easy to...
What you are reading right now is a preview ebook version of the book. This preview version is based on the Consumer Preview of Windows 8, which was released on February 29, 2012. Microsoft has ...
同时,教学重点是让学生学会使用存在和数量的句型:“Here is…”和“There is/There are…”。 在教学过程中,教师首先通过唱英文歌曲"Head and Shoulders"来预热课堂,复习身体部位的单词,强调单数形式的发音。...
But that is often the moment where you lack of time and that you are happy to find complete solutions. That is a moment where you tell to yourself “Is there no folk out there to give me such a ...
The goal here is to collect as much food as you can to make your snake grow, while you are exploding the blocks toat are blocking your way. Each time you hit a block, you lose a part of your snake. ...
2. **引起注意**:当某个事物出现或者到达时,可以使用 "Here is/are" 来吸引他人的注意力。例如:"Here comes the bus, let's hurry up."(公交车来了,我们快点。) 值得注意的是,"Here is" 后面通常跟名词或者...
I want to give you the bare minimum, with a little flavor, so that you have some foundational knowl- edge. With that in mind, I’ve sprinkled ideas and homework assignments throughout the book to ...
Well here it is, the TBMThread is a native VCL component implementing everything you do need to create the thread and the synchronization, just dropping the component on the form. Sounds great, right...
// If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef...
nonsense style of this book will help you get started by offering practical advice from someone who's been in your shoes and wants to help you learn quickly <br>The techniques and code examples ...
Of course the template files are predefined and so is the content of the project(s) within certain limits. However, I tried to choose the best options that I could think of and provide a way to ...
So, now that you know what objects are and that they expose methods that you can run and properties that you can inspect, you're ready to start coding. Coding in fact is simply about managing those ...
like which wild animals to avoid and whether naked snowboarding is a bad idea.” So how do you trick your brain into thinking that your life depends on knowing HTML5 and JavaScript? Intro Who is this ...