Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 6dd3068

Browse files
author
radeva
authored
Merge pull request #67 from NativeScript/tbozhikov/comply-with-seed
- comply with nativescript-plugin-seed - add demo webpack - add Travis CI checks
2 parents dc8e3d7 + fd9fb1d commit 6dd3068

File tree

107 files changed

+1773
-367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1773
-367
lines changed

.gitignore

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,22 @@
1-
# Logs
2-
logs
1+
.vscode
2+
.idea
3+
.DS_Store
4+
*.js
5+
*.js.map
36
*.log
4-
5-
# Runtime data
6-
pids
7-
*.pid
8-
*.seed
9-
10-
# Directory for instrumented libs generated by jscoverage/JSCover
11-
lib-cov
12-
13-
# Coverage directory used by tools like istanbul
14-
coverage
15-
16-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17-
.grunt
18-
19-
# node-waf configuration
20-
.lock-wscript
21-
22-
# Compiled binary addons (http://nodejs.org/api/addons.html)
23-
build/Release
24-
25-
# Dependency directory
26-
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
7+
logs
8+
!src/scripts/*.js
9+
!seed-tests/*.js
10+
seed-tests/seed-copy/**/*.*
11+
seed-tests/seed-copy-new-git-repo/**/*.*
12+
demo/app/*.js
13+
!demo/karma.conf.js
14+
!demo/app/tests/*.js
15+
demo/*.d.ts
16+
!demo/references.d.ts
17+
demo/lib
18+
demo/platforms
19+
demo/node_modules
2720
node_modules
28-
29-
# Dist directory where grunt script produces plugin installation files
30-
dist
31-
32-
#Exclude all javascript (js) files from source code
33-
source/**/*.js
34-
35-
#Exclude visual studio code local folder
36-
.vscode
21+
publish/src
22+
publish/package

.travis.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
matrix:
2+
include:
3+
- stage: "Lint"
4+
language: node_js
5+
os: linux
6+
node_js: "6"
7+
script: cd src && npm run ci.tslint && cd ../demo && npm run ci.tslint
8+
- stage: "WebPack"
9+
os: osx
10+
env:
11+
- Platform="iOS"
12+
osx_image: xcode8.3
13+
language: node_js
14+
node_js: "6"
15+
jdk: oraclejdk8
16+
script: cd demo && npm run build.plugin && npm i && npm run build-ios-bundle
17+
- language: android
18+
os: linux
19+
env:
20+
- Platform="Android"
21+
jdk: oraclejdk8
22+
before_install: nvm install 6.10.3
23+
script: cd demo && npm run build.plugin && npm i && npm run build-android-bundle
24+
- stage: "Build and Test"
25+
env:
26+
- BuildAndroid="25"
27+
language: android
28+
os: linux
29+
jdk: oraclejdk8
30+
before_install: nvm install stable
31+
script:
32+
- cd src && npm i && npm run tsc && cd ../demo && tns build android
33+
- os: osx
34+
env:
35+
- BuildiOS="10.3"
36+
- Xcode="8.3"
37+
osx_image: xcode8.3
38+
language: node_js
39+
node_js: "6"
40+
jdk: oraclejdk8
41+
script:
42+
- cd src && npm i && npm run tsc && cd ../demo && tns build ios
43+
- os: linux
44+
language: android
45+
dist: precise
46+
jdk: oraclejdk8
47+
before_script:
48+
- echo no | android create avd --force -n test -t android-21 -b armeabi-v7a
49+
- emulator -avd test -no-audio -no-window &
50+
- android-wait-for-emulator
51+
before_install:
52+
- nvm install 6
53+
script: cd src && npm run test.android
54+
- os: osx
55+
language: node_js
56+
node_js: "6"
57+
jdk: oraclejdk8
58+
osx_image: xcode8.3
59+
script: cd src && npm run test.ios
60+
61+
android:
62+
components:
63+
- tools
64+
- platform-tools
65+
- build-tools-25.0.2
66+
- android-25
67+
- extra-android-m2repository
68+
- sys-img-armeabi-v7a-android-21
69+
70+
install:
71+
- echo no | npm install -g nativescript
72+
- tns usage-reporting disable
73+
- tns error-reporting disable

README.md

Lines changed: 86 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,90 @@
1-
# nativescript-geolocation
1+
# NativeScript Geolocation ![apple](https://cdn3.iconfinder.com/data/icons/picons-social/57/16-apple-32.png) ![android](https://cdn4.iconfinder.com/data/icons/logos-3/228/android-32.png)
22

3-
Steps to compile the plugin.
43

5-
$ ./create.sh
4+
[![npm](https://img.shields.io/npm/v/nativescript-geolocation.svg)](https://www.npmjs.com/package/nativescript-geolocation)
5+
[![npm](https://img.shields.io/npm/dm/nativescript-geolocation.svg)](https://www.npmjs.com/package/nativescript-geolocation)
6+
[![Build Status](https://travis-ci.org/NativeScript/nativescript-geolocation.svg?branch=master)](https://travis-ci.org/NativeScript/nativescript-geolocation)
67

7-
This will produce a `dist` folder based on all JavaScript files within `source` folder. Values inside `source/package.json` controls the number of plugin version.
8+
Geolocation plugin to use for getting current location, monitor movement, etc.
89

9-
Sample application can be found here:
10-
https://github.com/NativeScript/nativescript-geolocation-demo
10+
## Installation
11+
12+
In Command prompt / Terminal navigate to your application root folder and run:
13+
14+
```
15+
tns plugin add nativescript-geolocation
16+
```
17+
18+
## Usage
19+
20+
The best way to explore the usage of the plugin is to inspect the demo app in the plugin's root folder.
21+
In `demo` folder you can find the usage of the plugin for TypeScript non-Angular application. Refer to `demo/app/main-page.ts`.
22+
23+
In short here are the steps:
24+
25+
### Import the plugin
26+
27+
*TypeScript*
28+
```
29+
import * as geolocation from "nativescript-geolocation";
30+
import { Accuracy } from "ui/enums"; // used to describe at what accuracy the location should be get
31+
```
32+
33+
*Javascript*
34+
```
35+
var geolocation = require("nativescript-geolocation");
36+
```
37+
38+
### Request permissions
39+
40+
```
41+
geolocation.enableLocationRequest();
42+
```
43+
44+
### Call plugin methods
45+
46+
````
47+
// Get current location with high accuracy
48+
geolocation.getCurrentLocation({ desiredAccuracy: Accuracy.high, updateDistance: 0.1, maximumAge: 5000, timeout: 20000 })
49+
````
50+
51+
## API
52+
53+
### Properties
54+
55+
#### Location
56+
57+
| Property | Default | Description |
58+
| --- | --- | --- |
59+
| latitude | - | The latitude of the geolocation, in degrees. |
60+
| longitude | - | The longitude of the geolocation, in degrees. |
61+
| altitude | - | The altitude (if available), in meters above sea level. |
62+
| horizontalAccuracy | - | The horizontal accuracy, in meters. |
63+
| verticalAccuracy | - | The vertical accuracy, in meters. |
64+
| speed | - | The speed, in meters/second over ground. |
65+
| timestamp | - | The time at which this location was determined. |
66+
67+
#### Options
68+
69+
| Property | Default | Description |
70+
| --- | --- | --- |
71+
| desiredAccuracy? | Accuracy.high | Specifies desired accuracy in meters. |
72+
| updateDistance | iOS - no filter, Android - 0 meters | Update distance filter in meters. Specifies how often to update the location. |
73+
| minimumUpdateTime | - | Minimum time interval between location updates, in milliseconds (ignored on iOS). |
74+
| maximumAge | - | How old locations to receive in ms. |
75+
| timeout | - | How long to wait for a location in ms. |
76+
77+
### Methods
78+
79+
| Method | Returns | Description |
80+
| --- | --- | --- |
81+
| getCurrentLocation(options: Options) | Promise<Location> | Get current location applying the specified options (if any). |
82+
| watchLocation(successCallback: successCallbackType, errorCallback: errorCallbackType, options: Options) | number | Monitor for location change. |
83+
| clearWatch(watchId: number) | void | Stop monitoring for location change. Parameter expected is the watchId returned from `watchLocation`. |
84+
| enableLocationRequest(always?: boolean) | Promise<void> | Ask for permissions to use location services. The option `always` is application for iOS only. [Read more about its usage](https://developer.apple.com/documentation/corelocation/cllocationmanager/1620551-requestalwaysauthorization) . |
85+
| isEnabled | boolean| Returns `true` if location services are enabled. |
86+
| distance(loc1: Location, loc2: Location) | number | Calculate the distance between two locations. Returns the distance in meters. |
87+
88+
## License
89+
90+
Apache License Version 2.0, January 2004

compile.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

create.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="__PACKAGE__"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
7+
<supports-screens
8+
android:smallScreens="true"
9+
android:normalScreens="true"
10+
android:largeScreens="true"
11+
android:xlargeScreens="true"/>
12+
13+
<uses-sdk
14+
android:minSdkVersion="17"
15+
android:targetSdkVersion="__APILEVEL__"/>
16+
17+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
18+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
19+
<uses-permission android:name="android.permission.INTERNET"/>
20+
21+
<application
22+
android:name="com.tns.NativeScriptApplication"
23+
android:allowBackup="true"
24+
android:icon="@drawable/icon"
25+
android:label="@string/app_name"
26+
android:theme="@style/AppTheme">
27+
28+
<activity
29+
android:name="com.tns.NativeScriptActivity"
30+
android:label="@string/title_activity_kimera"
31+
android:configChanges="keyboardHidden|orientation|screenSize"
32+
android:theme="@style/LaunchScreenTheme">
33+
34+
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
35+
36+
<intent-filter>
37+
<action android:name="android.intent.action.MAIN" />
38+
<category android:name="android.intent.category.LAUNCHER" />
39+
</intent-filter>
40+
</activity>
41+
<activity android:name="com.tns.ErrorReportActivity"/>
42+
</application>
43+
</manifest>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Add your native dependencies here:
2+
3+
// Uncomment to add recyclerview-v7 dependency
4+
//dependencies {
5+
// compile 'com.android.support:recyclerview-v7:+'
6+
//}
7+
8+
android {
9+
defaultConfig {
10+
generatedDensities = []
11+
applicationId = "org.nativescript.demo"
12+
}
13+
aaptOptions {
14+
additionalParameters "--no-version-vectors"
15+
}
16+
}
Loading
Loading
Loading

0 commit comments

Comments
 (0)