Skip to content

Commit efd5f64

Browse files
Fall back to web on Google, if Maps is not available #16
1 parent 6375822 commit efd5f64

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## [1.2.0](https://github.com/EddyVerbruggen/nativescript-directions/tree/1.2.0) (2018-02-09)
4+
[Full Changelog](https://github.com/EddyVerbruggen/nativescript-directions/compare/1.1.2...1.2.0)
5+
6+
**Implemented enhancements:**
7+
8+
- Fall back to web on Google, if Maps is not available [\#16](https://github.com/EddyVerbruggen/nativescript-directions/issues/16)
9+
310
## [1.1.2](https://github.com/EddyVerbruggen/nativescript-directions/tree/1.1.2) (2017-12-27)
411
[Full Changelog](https://github.com/EddyVerbruggen/nativescript-directions/compare/1.1.1...1.1.2)
512

demo/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"version": "3.4.0"
66
},
77
"tns-android": {
8-
"version": "3.4.0"
8+
"version": "3.4.1"
99
}
1010
},
1111
"dependencies": {
@@ -38,7 +38,8 @@
3838
"typescript": "~2.4.2",
3939
"webpack": "~3.8.1",
4040
"webpack-bundle-analyzer": "^2.8.2",
41-
"webpack-sources": "~1.0.1"
41+
"webpack-sources": "~1.0.1",
42+
"uglifyjs-webpack-plugin": "~1.1.6"
4243
},
4344
"scripts": {
4445
"generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install",

src/directions.android.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DirectionsApi, DirectionsCommon, NavigateToOptions } from "./directions.common";
22
import * as application from "tns-core-modules/application";
3+
import * as utils from "tns-core-modules/utils/utils";
34

4-
// ignore TS error
55
let com: any;
66

77
export class Directions extends DirectionsCommon implements DirectionsApi {
@@ -27,21 +27,19 @@ export class Directions extends DirectionsCommon implements DirectionsApi {
2727

2828
public navigate(options: NavigateToOptions): Promise<any> {
2929
return new Promise((resolve, reject) => {
30-
31-
if (!this.isPackageInstalled()) {
32-
// TODO fall back to web (see iOS impl)
33-
reject("Maps app not installed, use 'available' before using 'navigate'.");
34-
return;
35-
}
36-
3730
try {
3831
const fromToQs = Directions.getFromToQuerystring(options);
3932

40-
let intent = new android.content.Intent(
41-
android.content.Intent.ACTION_VIEW,
42-
android.net.Uri.parse("http://maps.google.com/maps" + fromToQs));
33+
if (!this.isPackageInstalled()) {
34+
// fall back to web
35+
utils.openUrl("http://maps.google.com/maps" + fromToQs);
36+
} else {
37+
const intent = new android.content.Intent(
38+
android.content.Intent.ACTION_VIEW,
39+
android.net.Uri.parse("http://maps.google.com/maps" + fromToQs));
4340

44-
application.android.currentContext.startActivityForResult(intent, 0);
41+
application.android.currentContext.startActivityForResult(intent, 0);
42+
}
4543

4644
resolve();
4745
} catch (e) {

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-directions",
3-
"version": "1.1.2",
3+
"version": "1.2.0",
44
"description": "Leverage the native Maps app to show directions from and to anywhere you like.",
55
"main": "directions",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)