Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ You will also need to set up your development environment. Please refer to the [
# Installation

```
$ tns plugin install @nativescript-community/ui-mapbox
$ ns plugin install @nativescript-community/ui-mapbox
```

# DEMOS
Expand All @@ -63,22 +63,25 @@ The style can be set to one of the Mapbox style names or it can be the URL of yo

> NOTE: As of this writing, the NativeScript demo only works with a mapbox token. The demo-angular will work with either a self hosted tile server or a mapbox token.

## Demo prerequisites
```
npm run setup
```


## To run the Angular demo

```
cd src
npm run build.release
cd ../demo-angular
tns run <platform>
npm run build
cd ./demo-angular
ns run <platform>
```

## To run the plain Nativescript demo

```
cd src
npm run build.release
cd ../demo
tns run <platform>
npm run build
cd ./demo
ns run <platform>
```

## Debug Build
Expand All @@ -96,7 +99,7 @@ sharing of mapping code between browser based and native applications.
## Issues

If you get an error during iOS build related to Podspec versions, probably the easiest fix is:
`tns platform remove ios` and `tns platform add ios`.
`ns platform remove ios` and `ns platform add ios`.

On Android the plugin adds this to the `<application>` node of `app/App_Resources/Android/AndroidManifest.xml` (the plugin already attempts to do so):

Expand Down
4 changes: 1 addition & 3 deletions demo/app/App_Resources/iOS/build.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
// for example you can uncomment the following line to force distribution code signing
// CODE_SIGN_IDENTITY = iPhone Distribution
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;

DEVELOPMENT_TEAM = 8Q5F6M3TNS
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
9 changes: 6 additions & 3 deletions demo/app/main-page.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:map="@nativescript-community/ui-mapbox" actionBarHidden="true" loaded="pageLoaded">
<TabView>
<TabView androidSwipeEnabled="false">
<TabView.items>

<TabViewItem title="Single Map">
Expand Down Expand Up @@ -103,7 +103,7 @@

<TabViewItem title="By Code">
<TabViewItem.view>
<GridLayout columns="*, *, *, *" rows="auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, *" horizontalAlignment="stretch" class="tab-content">
<GridLayout columns="*, *, *, *" rows="auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, *" horizontalAlignment="stretch" class="tab-content">

<Button row="0" col="0" text="show" tap="{{ doShow }}" class="button" />
<Button row="0" col="1" text="hide" tap="{{ doHide }}" class="button" />
Expand Down Expand Up @@ -150,7 +150,10 @@
<Button row="11" colSpan="2" text="location perm?" tap="{{ doCheckHasFineLocationPermission }}" class="button button-permissions" />
<Button row="11" col="2" colSpan="2" text="ask permission" tap="{{ doRequestFineLocationPermission }}" class="button button-permissions" />

<StackLayout row="12" col="0" colSpan="4">
<Button row="12" col="0" text="get layers" tap="{{ doGetLayers }}" class="button" />
<Button row="12" col="1" text="toggle all layers" tap="{{ doToggleLayers }}" class="button" />

<StackLayout row="13" col="0" colSpan="4">
<ContentView with="100%" height="100%" id="mapContainer" />
</StackLayout>

Expand Down
28 changes: 28 additions & 0 deletions demo/app/main-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,4 +824,32 @@ export class HelloWorldModel extends Observable {
console.log('Fine Location permission requested');
});
}

public doGetLayers(): void {
this.mapbox.getLayers().then((layers) => {
layers.map(l => console.log(l.id));

const alertOptions: AlertOptions = {
title: 'All map style layers',
message: JSON.stringify(layers.map(l => l.id)),
okButtonText: 'OK',
};
alert(alertOptions);
});

this.mapbox.getLayer('waterway').then((waterwayLayer) => {
if (!!waterwayLayer) {
console.log(`getLayer("${waterwayLayer.id}") visible?: ${waterwayLayer.visibility()}`);
}
})
}

public doToggleLayers(): void {
this.mapbox.getLayers().then((layers) => {
const everySecondElement = layers.filter((e, i) => i % 2 === 2 - 1);
everySecondElement.map((layer) => {
layer.visibility() ? layer.hide() : layer.show();
});
});
}
}
228 changes: 112 additions & 116 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,121 +1,117 @@
{
"name": "@nativescript-community/ui-mapbox",
"version": "5.0.0",
"description": "A Nativescript plugin for Mapbox Native Maps.",
"nativescript": {
"platforms": {
"android": "3.0.0",
"ios": "3.0.0"
"name": "@nativescript-community/ui-mapbox",
"version": "5.0.0",
"description": "A Nativescript plugin for Mapbox Native Maps.",
"nativescript": {
"platforms": {
"android": "3.0.0",
"ios": "3.0.0"
},
"plugin": {
"nan": true,
"pan": true,
"core3": "true",
"category": "Interface"
}
},
"plugin": {
"nan": true,
"pan": true,
"core3": "true",
"category": "Interface"
}
},
"scripts": {
"setup": "ts-patch install",
"build.angular": "ng-packagr -p src/angular/package.json -c src/angular/tsconfig.json",
"clean": "rimraf ./plugin/**/*.d.ts ./plugin/**/*.js ./plugin/**/*.js.map plugin/node_modules plugin/package-lock.json plugin/README.md demo/node_modules demo-angular/node_modules",
"tsc": "cpy '**/*.d.ts' '../plugin' --parents --cwd=src && tsc -skipLibCheck -d",
"build": "cp README.md ./plugin && rm -f .tsbuildinfo && npm run tsc ",
"publish": "npm run setup && npm run build && lerna publish --create-release=github",
"commitmsg": "commitlint -e $GIT_PARAMS",
"demo.ios": "npm run build && cd ../demo && tns run ios --syncAllFiles",
"demo.android": "npm run build && cd ../demo && tns run android",
"demo.android.build": "npm run build && cd ../demo && tns build android --log debug",
"test": "npm run tslint && npm run tslint.demo && cd ../demo && tns build ios && tns build android",
"test.ios": "cd ../demo && tns test ios --emulator --justlaunch",
"test.ios.device": "cd ../demo && tns test ios",
"test.android": "cd ../demo && tns test android --justlaunch",
"eslint": "eslint 'src/**/*.ts' --fix",
"prepublishOnly": "npm run build",
"generate.typings.ios": "cd ../demo && TNS_DEBUG_METADATA_PATH=\"$(pwd)/metadata\" tns build ios && TNS_TYPESCRIPT_DECLARATIONS_PATH=\"$(pwd)/typings\" tns build ios && echo 'Now look for your library typings in demo/typings!'",
"demo-angular.reset": "cd ../demo-angular && npx rimraf -- hooks node_modules platforms package-lock.json",
"demo.reset": "cd ../demo && npx rimraf -- hooks node_modules platforms package-lock.json"
},
"repository": {
"type": "git",
"url": "https://github.com/nativescript-community/ui-mapbox.git"
},
"keywords": [
"ecosystem:nativescript",
"NativeScript",
"Map",
"Maps",
"Native Maps",
"Mapbox"
],
"author": {
"name": "Yermo Lamers",
"email": "yml@yml.com",
"url": "https://miles-by-motorcycle.com/flyingbricksoftware/about"
},
"contributors": [
{
"name": "Eddy Verbruggen - Original Author",
"email": "eddyverbruggen@gmail.com"
"scripts": {
"setup": "npm i && ts-patch install",
"build.angular": "ng-packagr -p src/angular/package.json -c src/angular/tsconfig.json",
"clean": "rimraf ./plugin/**/*.d.ts ./plugin/**/*.js ./plugin/**/*.js.map plugin/node_modules plugin/package-lock.json plugin/README.md demo/node_modules demo-angular/node_modules",
"tsc": "cpy '**/*.d.ts' '../plugin' --parents --cwd=src && tsc -skipLibCheck -d",
"build": "cp README.md ./plugin && rm -f .tsbuildinfo && npm run tsc ",
"publish": "npm run setup && npm run build && lerna publish --create-release=github",
"commitmsg": "commitlint -e $GIT_PARAMS",
"demo.ios": "npm run build && cd ./demo && ns run ios",
"demo.android": "npm run build && cd ./demo && ns run android",
"demo.android.build": "npm run build && cd ./demo && ns build android --log debug",
"eslint": "eslint 'src/**/*.ts' --fix",
"prepublishOnly": "npm run build",
"generate.typings.ios": "cd ./demo && TNS_DEBUG_METADATA_PATH=\"$(pwd)/metadata\" ns build ios && TNS_TYPESCRIPT_DECLARATIONS_PATH=\"$(pwd)/typings\" ns build ios && echo 'Now look for your library typings in demo/typings!'",
"demo-angular.reset": "cd ./demo-angular && ns clean",
"demo.reset": "cd ./demo && ns clean"
},
"repository": {
"type": "git",
"url": "https://github.com/nativescript-community/ui-mapbox.git"
},
"keywords": [
"ecosystem:nativescript",
"NativeScript",
"Map",
"Maps",
"Native Maps",
"Mapbox"
],
"author": {
"name": "Yermo Lamers",
"email": "yml@yml.com",
"url": "https://miles-by-motorcycle.com/flyingbricksoftware/about"
},
"contributors": [
{
"name": "Eddy Verbruggen - Original Author",
"email": "eddyverbruggen@gmail.com"
},
{
"name": "Alex Wells",
"email": "autaut03@gmail.com"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/nativescript-community/ui-mapbox/issues"
},
"homepage": "https://github.com/nativescript-community/ui-mapbox",
"readmeFilename": "README.md",
"devDependencies": {
"@angular/animations": "~10.1.5",
"@angular/common": "~10.1.5",
"@angular/compiler": "~10.1.5",
"@angular/compiler-cli": "~10.1.5",
"@angular/core": "~10.1.5",
"@angular/forms": "~10.1.5",
"@angular/platform-browser": "~10.1.5",
"@angular/platform-browser-dynamic": "11.0.0-rc.3",
"@angular/router": "~10.1.5",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@nativescript-community/perms": "^2.1.1",
"@nativescript/angular": "10.1.7",
"@nativescript/core": "7.0.13",
"@nativescript/ios": "7.0.5",
"@nativescript/types-android": "~7.0.4",
"@nativescript/types-ios": "~7.0.4",
"@nativescript/webpack": "3.0.8",
"@types/node": "14.14.7",
"@types/react": "16.9.56",
"@typescript-eslint/eslint-plugin": "4.7.0",
"@typescript-eslint/parser": "4.7.0",
"cpy-cli": "^3.1.1",
"eslint": "7.13.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0",
"lerna": "^3.22.1",
"ng-packagr": "~10.1.2",
"prettier": "^2.1.2",
"prompt": "^1.0.0",
"react-nativescript": "^2.1.0",
"rimraf": "^3.0.2",
"rxjs": "^6.6.3",
"svelte-native": "0.9.5",
"ts-patch": "^1.3.0",
"tslib": "2.0.3",
"typescript": "3.9.7",
"zone.js": "0.11.3",
"vue": "^2.6.12"
},
"dependencies": {
"ts-node": "^9.0.0"
},
{
"name": "Alex Wells",
"email": "autaut03@gmail.com"
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/nativescript-community/ui-mapbox/issues"
},
"homepage": "https://github.com/nativescript-community/ui-mapbox",
"readmeFilename": "README.md",
"devDependencies": {
"@angular/animations": "~10.1.5",
"@angular/common": "~10.1.5",
"@angular/compiler": "~10.1.5",
"@angular/compiler-cli": "~10.1.5",
"@angular/core": "~10.1.5",
"@angular/forms": "~10.1.5",
"@angular/platform-browser": "~10.1.5",
"@angular/platform-browser-dynamic": "11.0.0-rc.3",
"@angular/router": "~10.1.5",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@nativescript-community/perms": "^2.1.1",
"@nativescript/angular": "10.1.7",
"@nativescript/core": "7.0.13",
"@nativescript/ios": "7.0.5",
"@nativescript/types-android": "~7.0.4",
"@nativescript/types-ios": "~7.0.4",
"@nativescript/webpack": "3.0.8",
"@types/node": "14.14.7",
"@types/react": "16.9.56",
"@typescript-eslint/eslint-plugin": "4.7.0",
"@typescript-eslint/parser": "4.7.0",
"cpy-cli": "^3.1.1",
"eslint": "7.13.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0",
"lerna": "^3.22.1",
"ng-packagr": "~10.1.2",
"prettier": "^2.1.2",
"prompt": "^1.0.0",
"react-nativescript": "^2.1.0",
"rimraf": "^3.0.2",
"rxjs": "^6.6.3",
"svelte-native": "0.9.5",
"ts-patch": "^1.3.0",
"tslib": "2.0.3",
"typescript": "3.9.7",
"zone.js": "0.11.3",
"vue": "^2.6.12"
},
"dependencies": {
"ts-node": "^9.0.0"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
}
}
Loading