快速 上手centos7命令
2015-10-07 18:30
477 查看
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:
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:
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:
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:
geo.js does
not currently support the watchPosition() function.
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.
相关文章推荐
- CentOS中文显示设置
- Linux多线程基础学习(二)创建新的线程
- 我在GNU/Linux下使用的桌面环境工具组合
- 第2章 linux学习方法
- Linux初接触设置笔记01
- centos6.4设备hadoop-2.5.1(完全分布式)
- 第1章 linux概述
- Linux服务--iptables之nat转发和构建简单的DMZ防火墙
- 【译】29个你必须知道的Linux命令
- linux下python的机器学习包scikit-learn(包含numpy、scipy等)安装
- linux运维实战练习-2015年9月13日-9月15日课程作业
- Linux下FTP设置
- linux中断子系统(三) - 中断调用过程
- Linux学习记录
- 转载自~浮云比翼:Step by Step:Linux C多线程编程入门(基本API及多线程的同步与互斥)
- win7+kali linux 双系统 时间同步
- Redhat/CentOS系统KVM虚拟机安装过程详解
- Python Linux下安装python 软件包
- centos 6.5 搭建dhcp服务器
- linux下的打包压缩和解压命令