<!--
# license: Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-->
# cordova-plugin-geolocation
[![Build Status](https://travis-ci.org/apache/cordova-plugin-geolocation.svg)](https://travis-ci.org/apache/cordova-plugin-geolocation)
このプラグインは緯度や経度などのデバイスの場所に関する情報を提供します。 位置情報の共通のソースはグローバル ポジショニング システム (GPS) と IP アドレス、RFID、WiFi および Bluetooth の MAC アドレス、および GSM/cdma 方式携帯 Id などのネットワーク信号から推定される場所にもあります。 API は、デバイスの実際の場所を返すことの保証はありません。
この API は[W3C 地理位置情報 API 仕様](http://dev.w3.org/geo/api/spec-source.html)に基づいており、既に実装を提供しないデバイス上のみで実行します。
**警告**: 地理位置情報データの収集と利用を重要なプライバシーの問題を発生させます。 アプリのプライバシー ポリシーは他の当事者とデータ (たとえば、粗い、罰金、郵便番号レベル、等) の精度のレベルでは共有されているかどうか、アプリが地理位置情報データを使用する方法を議論すべきです。 地理位置情報データと一般に見なされる敏感なユーザーの居場所を開示することができますので、彼らの旅行の歴史保存されている場合。 したがって、アプリのプライバシー ポリシーに加えて、強くする必要があります (デバイス オペレーティング システムしない場合そう既に)、アプリケーションに地理位置情報データをアクセスする前に - 時間のお知らせを提供します。 その通知は、上記の (例えば、 **[ok]**を**おかげで**選択肢を提示する) によってユーザーのアクセス許可を取得するだけでなく、同じ情報を提供する必要があります。 詳細については、プライバシーに関するガイドを参照してください。
このプラグインは、グローバル `navigator.geolocation` オブジェクト (プラットフォーム行方不明ですそれ以外の場合) を定義します。
オブジェクトは、グローバル スコープでですが、このプラグインによって提供される機能は、`deviceready` イベントの後まで使用できません。
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log("navigator.geolocation works well");
}
## インストール
これはコルドバ 5.0 + (現在安定 1.0.0) を必要とします。
cordova plugin add cordova-plugin-geolocation
コルドバの古いバージョンでも非推奨 id (古い 0.3.12 と) 経由でインストールできます。
cordova plugin add org.apache.cordova.geolocation
また、レポの url 経由で直接インストールすることが可能だ (不安定)
cordova plugin add https://github.com/apache/cordova-plugin-geolocation.git
## サポートされているプラットフォーム
* アマゾン火 OS
* アンドロイド
* ブラックベリー 10
* Firefox の OS
* iOS
* Tizen
* Windows Phone 7 と 8
* Windows 8
* Windows
## メソッド
* navigator.geolocation.getCurrentPosition
* navigator.geolocation.watchPosition
* navigator.geolocation.clearWatch
## オブジェクト (読み取り専用)
* Position
* PositionError
* Coordinates
## navigator.geolocation.getCurrentPosition
`Position` オブジェクトを `geolocationSuccess` コールバックにパラメーターとしてデバイスの現在位置を返します。 エラーがある場合 `geolocationError` コールバックには、`PositionError` オブジェクトが渡されます。
navigator.geolocation.getCurrentPosition(geolocationSuccess,
[geolocationError],
[geolocationOptions]);
### パラメーター
* **geolocationSuccess**: 現在の位置を渡されるコールバック。
* **geolocationError**: *(省略可能)*エラーが発生した場合に実行されるコールバック。
* **geolocationOptions**: *(オプション)*地理位置情報のオプションです。
### 例
// onSuccess Callback
// This method accepts a Position object, which contains the
// current GPS coordinates
//
var onSuccess = function(position) {
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
};
// onError Callback receives a PositionError object
//
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);
## navigator.geolocation.watchPosition
位置の変更が検出された場合は、デバイスの現在位置を返します。 取得されると、デバイスの新しい場所、`geolocationSuccess` コールバック パラメーターとして `位置` オブジェクトを実行します。 エラーがある場合、`geolocationError` コールバック パラメーターとして `PositionError` オブジェクトで実行します。
var watchId = navigator.geolocation.watchPosition(geolocationSuccess,
[geolocationError],
[geolocationOptions]);
### パラメーター
* **geolocationSuccess**: 現在の位置を渡されるコールバック。
* **geolocationError**: (省略可能) エラーが発生した場合に実行されるコールバック。
* **geolocationOptions**: (オプション) 地理位置情報のオプションです。
### 返します
* **文字列**: 時計の位置の間隔を参照する時計 id を返します。 時計 id で使用する必要があります `navigator.geolocation.clearWatch` 停止位置の変化を監視します。
### 例
// onSuccess Callback
// This method accepts a `Position` object, which contains
// the current GPS coordinates
//
function onSuccess(position) {
var element = document.getElementById('geolocation');
element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' +
没有合适的资源?快使用搜索试试~ 我知道了~
位置分享APP项目源码
共154个文件
scss:40个
js:34个
md:32个
4星 · 超过85%的资源 需积分: 13 183 下载量 12 浏览量
2016-04-14
11:20:07
上传
评论 9
收藏 2.09MB RAR 举报
温馨提示
“位置分享”App正如其名称所述那样,是一款可以分享自己地理位置的应用。“位置分享”App的功能需求大致如下: 1、可以获取自己的当前位置,并在地图中展示出来; 2、可以将自己的位置信息发送到云端数据库保存; 3、可以导航到目标用户的所在位置;注:目标用户必须是注册过的用户,而且对方发送过自己的位置信息到云端。这两点很重要,一是直接导航到任何一个用户是不可能的,除非你是FBI(呵呵)。二是如果想导航到注册的任何一个用户,除非app定时自动发送位置信息到云端,这点实现起来比较复杂,而且与我们的主题Ionic+Cordova+Bmob无关,因此就不搞这么复杂。 4、可以查看某用户的历史足迹,并在地图中标出;注:前提是对方发送过自己的位置信息到云端。 5、基本的注册、登录、注销和个人信息查看功能。
资源推荐
资源详情
资源评论
收起资源包目录
位置分享APP项目源码 (154个子文件)
geolocation.cpp 4KB
GeoLocation.cs 1KB
ionic.css 243KB
ionic.min.css 192KB
style.css 42B
ionicons.eot 118KB
CDVLocation.h 2KB
geolocation.h 2KB
account-register.html 3KB
account-login.html 2KB
track-traceHistory.html 2KB
index.html 1KB
tab-account.html 1KB
track-trace.html 1KB
tabs.html 851B
tab-track.html 604B
tab-dash.html 402B
www.iml 281B
PermissionHelper.java 8KB
WhitelistPlugin.java 6KB
Geolocation.java 3KB
ionic.bundle.js 2.17MB
angular.js 1017KB
ionic.bundle.min.js 482KB
ionic.js 458KB
ionic-angular.js 436KB
bmob.js 256KB
ionic.min.js 162KB
angular-ui-router.js 153KB
angular.min.js 142KB
angular-animate.js 131KB
ionic-angular.min.js 120KB
bmobSocketIo.js 107KB
bmob-min.js 86KB
bmobSocketIo-min.js 55KB
angular-ui-router.min.js 28KB
angular-resource.js 26KB
angular-sanitize.js 24KB
angular-animate.min.js 23KB
controllers.js 21KB
tests.js 18KB
geolocation.js 8KB
GeolocationProxy.js 7KB
angular-sanitize.min.js 6KB
angular-resource.min.js 4KB
app.js 3KB
geolocation.js 3KB
GeolocationProxy.js 2KB
services.js 2KB
GeolocationProxy.js 2KB
Coordinates.js 2KB
PositionError.js 1KB
Position.js 1KB
whitelist.js 1KB
filter.js 257B
package.json 854B
package.json 536B
fetch.json 421B
android.json 402B
version.json 89B
LICENSE 11KB
LICENSE 11KB
CDVLocation.m 14KB
index.md 15KB
README.md 13KB
index.md 13KB
README.md 12KB
README.md 12KB
README.md 12KB
README.md 12KB
README.md 12KB
README.md 12KB
index.md 11KB
index.md 11KB
index.md 11KB
index.md 11KB
README.md 11KB
index.md 11KB
index.md 11KB
README.md 11KB
index.md 10KB
RELEASENOTES.md 9KB
README.md 7KB
README.md 7KB
README.md 7KB
README.md 7KB
README.md 7KB
README.md 7KB
README.md 6KB
README.md 6KB
README.md 6KB
RELEASENOTES.md 3KB
CONTRIBUTING.md 1KB
CONTRIBUTING.md 1KB
README.md 1KB
.name 3B
NOTICE 163B
NOTICE 163B
icon_2.png 82KB
track.png 65KB
共 154 条
- 1
- 2
资源评论
- zouqone2017-03-21我怎么下载不了
- kinglike2017-02-25还行,有借鉴的价值。
- cx43594812016-09-02不错 有参考价值 谢谢
GAMELOFT9
- 粉丝: 227
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功