New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-geolocation

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-geolocation - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

.github/PULL_REQUEST_TEMPLATE.md

9

package.json
{
"name": "cordova-plugin-geolocation",
"version": "2.2.0",
"version": "2.3.0",
"description": "Cordova Geolocation Plugin",

@@ -45,2 +45,9 @@ "cordova": {

"license": "Apache-2.0",
"engines": {
"cordovaDependencies": {
"3.0.0": {
"cordova": ">100"
}
}
},
"devDependencies": {

@@ -47,0 +54,0 @@ "jshint": "^2.6.0"

@@ -0,1 +1,5 @@

---
title: Geolocation
description: Access GPS data.
---
<!--

@@ -20,3 +24,5 @@ # license: Licensed to the Apache Software Foundation (ASF) under one

[![Build Status](https://travis-ci.org/apache/cordova-plugin-geolocation.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-geolocation)
|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI |
|:-:|:-:|:-:|:-:|:-:|:-:|
|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-geolocation.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-geolocation)|

@@ -26,3 +32,5 @@ # cordova-plugin-geolocation

This plugin provides information about the device's location, such as
latitude and longitude. Common sources of location information include
latitude and longitude.
Common sources of location information include
Global Positioning System (GPS) and location inferred from network

@@ -33,2 +41,4 @@ signals such as IP address, RFID, WiFi and Bluetooth MAC addresses,

> To get a few ideas, check out the [sample](#sample) at the bottom of this page or go straight to the [reference](#reference) content.
This API is based on the

@@ -59,2 +69,4 @@ [W3C Geolocation API Specification](http://dev.w3.org/geo/api/spec-source.html),

```javascript
document.addEventListener("deviceready", onDeviceReady, false);

@@ -65,2 +77,4 @@ function onDeviceReady() {

```
## <a id="reference"></a>Reference
## Installation

@@ -125,2 +139,4 @@

```javascript
// onSuccess Callback

@@ -150,2 +166,4 @@ // This method accepts a Position object, which contains the

```
### Android Quirks

@@ -182,2 +200,4 @@

```javascript
// onSuccess Callback

@@ -205,2 +225,3 @@ // This method accepts a `Position` object, which contains

```

@@ -240,2 +261,4 @@ ## geolocationOptions

```javascript
// Options: watch for changes in position, and use the most

@@ -250,2 +273,4 @@ // accurate position acquisition method available.

```
## Position

@@ -310,1 +335,436 @@

- Returned when the device is unable to retrieve a position within the time specified by the `timeout` included in `geolocationOptions`. When used with `navigator.geolocation.watchPosition`, this error could be repeatedly passed to the `geolocationError` callback every `timeout` milliseconds.
## <a id="sample"></a>Sample: Get the weather, find stores, and see photos of things nearby with Geolocation ##
Use this plugin to help users find things near them such as Groupon deals, houses for sale, movies playing, sports and entertainment events and more.
Here's a "cookbook" of ideas to get you started. In the snippets below, we'll show you some basic ways to add these features to your app.
* [Get your coordinates](#coords).
* [Get the weather forecast](#weather).
* [Receive updated weather forecasts as you drive around](#receive).
* [See where you are on a map](#see).
* [Find stores near you](#find).
* [See pictures of things around you](#see).
## <a id="coord"></a>Get your geolocation coordinates
```javascript
function getWeatherLocation() {
navigator.geolocation.getCurrentPosition
(onWeatherSuccess, onWeatherError, { enableHighAccuracy: true });
}
```
## <a id="weather"></a>Get the weather forecast
```javascript
// Success callback for get geo coordinates
var onWeatherSuccess = function (position) {
Latitude = position.coords.latitude;
Longitude = position.coords.longitude;
getWeather(Latitude, Longitude);
}
// Get weather by using coordinates
function getWeather(latitude, longitude) {
// Get a free key at http://openweathermap.org/. Replace the "Your_Key_Here" string with that key.
var OpenWeatherAppKey = "Your_Key_Here";
var queryString =
'http://api.openweathermap.org/data/2.5/weather?lat='
+ latitude + '&lon=' + longitude + '&appid=' + OpenWeatherAppKey + '&units=imperial';
$.getJSON(queryString, function (results) {
if (results.weather.length) {
$.getJSON(queryString, function (results) {
if (results.weather.length) {
$('#description').text(results.name);
$('#temp').text(results.main.temp);
$('#wind').text(results.wind.speed);
$('#humidity').text(results.main.humidity);
$('#visibility').text(results.weather[0].main);
var sunriseDate = new Date(results.sys.sunrise);
$('#sunrise').text(sunriseDate.toLocaleTimeString());
var sunsetDate = new Date(results.sys.sunrise);
$('#sunset').text(sunsetDate.toLocaleTimeString());
}
});
}
}).fail(function () {
console.log("error getting location");
});
}
// Error callback
function onWeatherError(error) {
console.log('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
```
## <a id="receive"></a>Receive updated weather forecasts as you drive around
```javascript
// Watch your changing position
function watchWeatherPosition() {
return navigator.geolocation.watchPosition
(onWeatherWatchSuccess, onWeatherError, { enableHighAccuracy: true });
}
// Success callback for watching your changing position
var onWeatherWatchSuccess = function (position) {
var updatedLatitude = position.coords.latitude;
var updatedLongitude = position.coords.longitude;
if (updatedLatitude != Latitude && updatedLongitude != Longitude) {
Latitude = updatedLatitude;
Longitude = updatedLongitude;
// Calls function we defined earlier.
getWeather(updatedLatitude, updatedLongitude);
}
}
```
## <a id="see"></a>See where you are on a map
Both Bing and Google have map services. We'll use Google's. You'll need a key but it's free if you're just trying things out.
Add a reference to the **maps** service.
```HTML
<script src="https://maps.googleapis.com/maps/api/js?key=Your_API_Key"></script>
```
Then, add code to use it.
```javascript
var Latitude = undefined;
var Longitude = undefined;
// Get geo coordinates
function getMapLocation() {
navigator.geolocation.getCurrentPosition
(onMapSuccess, onMapError, { enableHighAccuracy: true });
}
// Success callback for get geo coordinates
var onMapSuccess = function (position) {
Latitude = position.coords.latitude;
Longitude = position.coords.longitude;
getMap(Latitude, Longitude);
}
// Get map by using coordinates
function getMap(latitude, longitude) {
var mapOptions = {
center: new google.maps.LatLng(0, 0),
zoom: 1,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map
(document.getElementById("map"), mapOptions);
var latLong = new google.maps.LatLng(latitude, longitude);
var marker = new google.maps.Marker({
position: latLong
});
marker.setMap(map);
map.setZoom(15);
map.setCenter(marker.getPosition());
}
// Success callback for watching your changing position
var onMapWatchSuccess = function (position) {
var updatedLatitude = position.coords.latitude;
var updatedLongitude = position.coords.longitude;
if (updatedLatitude != Latitude && updatedLongitude != Longitude) {
Latitude = updatedLatitude;
Longitude = updatedLongitude;
getMap(updatedLatitude, updatedLongitude);
}
}
// Error callback
function onMapError(error) {
console.log('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
// Watch your changing position
function watchMapPosition() {
return navigator.geolocation.watchPosition
(onMapWatchSuccess, onMapError, { enableHighAccuracy: true });
}
```
## <a id="find"></a>Find stores near you
You can use the same Google key for this.
Add a reference to the **places** service.
```HTML
<script src=
"https://maps.googleapis.com/maps/api/js?key=Your_API_Key&libraries=places">
</script>
```
Then, add code to use it.
```javascript
var Map;
var Infowindow;
var Latitude = undefined;
var Longitude = undefined;
// Get geo coordinates
function getPlacesLocation() {
navigator.geolocation.getCurrentPosition
(onPlacesSuccess, onPlacesError, { enableHighAccuracy: true });
}
// Success callback for get geo coordinates
var onPlacesSuccess = function (position) {
Latitude = position.coords.latitude;
Longitude = position.coords.longitude;
getPlaces(Latitude, Longitude);
}
// Get places by using coordinates
function getPlaces(latitude, longitude) {
var latLong = new google.maps.LatLng(latitude, longitude);
var mapOptions = {
center: new google.maps.LatLng(latitude, longitude),
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
Map = new google.maps.Map(document.getElementById("places"), mapOptions);
Infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(Map);
service.nearbySearch({
location: latLong,
radius: 500,
type: ['store']
}, foundStoresCallback);
}
// Success callback for watching your changing position
var onPlacesWatchSuccess = function (position) {
var updatedLatitude = position.coords.latitude;
var updatedLongitude = position.coords.longitude;
if (updatedLatitude != Latitude && updatedLongitude != Longitude) {
Latitude = updatedLatitude;
Longitude = updatedLongitude;
getPlaces(updatedLatitude, updatedLongitude);
}
}
// Success callback for locating stores in the area
function foundStoresCallback(results, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
}
}
}
// Place a pin for each store on the map
function createMarker(place) {
var placeLoc = place.geometry.location;
var marker = new google.maps.Marker({
map: Map,
position: place.geometry.location
});
google.maps.event.addListener(marker, 'click', function () {
Infowindow.setContent(place.name);
Infowindow.open(Map, this);
});
}
// Error callback
function onPlacesError(error) {
console.log('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
// Watch your changing position
function watchPlacesPosition() {
return navigator.geolocation.watchPosition
(onPlacesWatchSuccess, onPlacesError, { enableHighAccuracy: true });
}
```
## <a id="pictures"></a>See pictures of things around you
Digital photos can contain geo coordinates that identify where the picture was taken.
Use Flickr API's to find pictures that folks have taken near you. Like Google services, you'll need a key, but it's free if you just want to try things out.
```javascript
var Latitude = undefined;
var Longitude = undefined;
// Get geo coordinates
function getPicturesLocation() {
navigator.geolocation.getCurrentPosition
(onPicturesSuccess, onPicturesError, { enableHighAccuracy: true });
}
// Success callback for get geo coordinates
var onPicturesSuccess = function (position) {
Latitude = position.coords.latitude;
Longitude = position.coords.longitude;
getPictures(Latitude, Longitude);
}
// Get pictures by using coordinates
function getPictures(latitude, longitude) {
$('#pictures').empty();
var queryString =
"https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=Your_API_Key&lat="
+ latitude + "&lon=" + longitude + "&format=json&jsoncallback=?";
$.getJSON(queryString, function (results) {
$.each(results.photos.photo, function (index, item) {
var photoURL = "http://farm" + item.farm + ".static.flickr.com/" +
item.server + "/" + item.id + "_" + item.secret + "_m.jpg";
$('#pictures').append($("<img />").attr("src", photoURL));
});
}
);
}
// Success callback for watching your changing position
var onPicturesWatchSuccess = function (position) {
var updatedLatitude = position.coords.latitude;
var updatedLongitude = position.coords.longitude;
if (updatedLatitude != Latitude && updatedLongitude != Longitude) {
Latitude = updatedLatitude;
Longitude = updatedLongitude;
getPictures(updatedLatitude, updatedLongitude);
}
}
// Error callback
function onPicturesError(error) {
console.log('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
// Watch your changing position
function watchPicturePosition() {
return navigator.geolocation.watchPosition
(onPicturesWatchSuccess, onPicturesError, { enableHighAccuracy: true });
}
```

35

RELEASENOTES.md

@@ -23,20 +23,29 @@ <!--

### 2.3.0 (Sep 08, 2016)
* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
* Plugin uses `Android Log class` and not `Cordova LOG class`
* Add badges for paramedic builds on Jenkins
* Add pull request template.
* Adding links to reference content and sample content to the top of the readme file
* Update **iOS** geolocation plugin to avoid `THREAD WARNING: ['Geolocation']`, operation occurs in new Thread
* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
### 2.2.0 (Apr 15, 2016)
* Replace `PermissionHelper.java` with `cordova-plugin-compat`
* CB-10691 Check the context to avoid null errors
* CB-10636 Add `JSHint` for plugins
* [CB-10691](https://issues.apache.org/jira/browse/CB-10691) Check the context to avoid null errors
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins
* Using a fallback epsilon in case `Number.EPSILON` is not defined.
* CB-10574 MobileSpec can't get results for **WP8.1** Builds
* [CB-10574](https://issues.apache.org/jira/browse/CB-10574) MobileSpec can't get results for **WP8.1** Builds
### 2.1.0 (Jan 15, 2016)
* CB-10319 **Android** Adding reflective helper methods for permission requests
* CB-8523 Fixed accuracy when `enableHighAccuracy: false` on **iOS**.
* CB-10286 Don't skip automatic tests on **Android** devices
* CB-10277 Error callback should be called w/ `PositionError` when location access is denied
* CB-10285 Added tests for `PositionError` constants
* CB-10278 geolocation `watchPosition` doesn't return `watchID` string
* CB-8443 **Android** nothing happens if `GPS` is turned off
* CB-10204 Fix `getCurrentPosition` options on **Android**
* CB-7146 Remove built-in `WebView navigator.geolocation` manual tests
* CB-2845 `PositionError` constants not attached to prototype as specified in W3C document
* [CB-10319](https://issues.apache.org/jira/browse/CB-10319) **Android** Adding reflective helper methods for permission requests
* [CB-8523](https://issues.apache.org/jira/browse/CB-8523) Fixed accuracy when `enableHighAccuracy: false` on **iOS**.
* [CB-10286](https://issues.apache.org/jira/browse/CB-10286) Don't skip automatic tests on **Android** devices
* [CB-10277](https://issues.apache.org/jira/browse/CB-10277) Error callback should be called w/ `PositionError` when location access is denied
* [CB-10285](https://issues.apache.org/jira/browse/CB-10285) Added tests for `PositionError` constants
* [CB-10278](https://issues.apache.org/jira/browse/CB-10278) geolocation `watchPosition` doesn't return `watchID` string
* [CB-8443](https://issues.apache.org/jira/browse/CB-8443) **Android** nothing happens if `GPS` is turned off
* [CB-10204](https://issues.apache.org/jira/browse/CB-10204) Fix `getCurrentPosition` options on **Android**
* [CB-7146](https://issues.apache.org/jira/browse/CB-7146) Remove built-in `WebView navigator.geolocation` manual tests
* [CB-2845](https://issues.apache.org/jira/browse/CB-2845) `PositionError` constants not attached to prototype as specified in W3C document

@@ -43,0 +52,0 @@ ### 2.0.0 (Nov 18, 2015)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc