├── references.d.ts ├── .github ├── FUNDING.yml └── workflows │ └── release.yml ├── pnpm-workspace.yaml ├── .prettierignore ├── packages └── ui-mapbox │ ├── .npmignore │ ├── nativescript.config.ts │ ├── platforms │ ├── ios │ │ ├── Resources │ │ │ └── default_pin.png │ │ ├── Podfile │ │ ├── Info.plist │ │ └── src │ │ │ ├── NativeExpressionParser.swift │ │ │ └── NativeLayerFactory.swift │ └── android │ │ ├── AndroidManifest.xml │ │ ├── buildscript.gradle │ │ ├── res │ │ └── drawable │ │ │ └── ic_red_marker.xml │ │ ├── include.gradle │ │ └── java │ │ └── com │ │ └── nativescript │ │ └── mapbox │ │ └── Utils.kt │ ├── tsconfig.json │ └── package.json ├── images ├── preview.png ├── mapbox_logo.png ├── ios-xml-declared.png └── ios-demoapp-slice.png ├── .yarnrc.yml ├── config.json ├── eslint.config.mjs ├── src └── ui-mapbox │ ├── typings │ ├── Mapbox.ios.d.ts │ └── index.android.d.ts │ ├── expression │ ├── expression-parser.d.ts │ ├── expression-parser.android.ts │ └── expression-parser.ios.ts │ ├── layers │ ├── parser │ │ ├── property-parser.d.ts │ │ ├── property-parser.ios.ts │ │ └── property-parser.android.ts │ ├── layer-factory.d.ts │ └── layer-factory.ios.ts │ ├── README.md │ ├── references.d.ts │ ├── geo.utils.ts │ └── markers │ ├── Marker.common.ts │ └── Marker.android.ts ├── docs ├── .nojekyll ├── assets │ ├── hierarchy.js │ ├── navigation.js │ └── highlight.css ├── variables │ ├── MapboxTraceCategory.html │ ├── delayProperty.html │ ├── hideLogoProperty.html │ ├── latitudeProperty.html │ ├── mapStyleProperty.html │ ├── longitudeProperty.html │ ├── telemetryProperty.html │ ├── zoomLevelProperty.html │ ├── accessTokenProperty.html │ ├── disableTiltProperty.html │ ├── disableZoomProperty.html │ ├── hideCompassProperty.html │ ├── disableScrollProperty.html │ ├── disableRotationProperty.html │ ├── hideAttributionProperty.html │ ├── showUserLocationProperty.html │ ├── logoPositionProperty.html │ ├── locationComponentOptionsProperty.html │ ├── compassPositionProperty.html │ ├── attributionPositionProperty.html │ └── mapReadyProperty.html └── types │ ├── AddSourceOptions.html │ ├── UpdateSourceOptions.html │ ├── UserTrackingMode.html │ ├── SupportedLayerType.html │ └── UserLocationCameraMode.html ├── demo-snippets ├── ng │ ├── mapbox-token.ts │ ├── mapbox-demo2 │ │ ├── mapbox-demo2.component.html │ │ └── mapbox-demo2.component.ts │ ├── mapbox-demo3 │ │ ├── mapbox-demo3.component.html │ │ ├── mapbox-demo3.module.ts │ │ └── mapbox-demo3.component.ts │ ├── basic-map │ │ ├── basic-map.component.ts │ │ └── basic-map.component.html │ ├── mapbox-footer │ │ └── mapbox-footer.component.ts │ ├── mapbox-demo │ │ ├── mapbox-demo.component.html │ │ └── mapbox-demo.component.ts │ ├── install.module.ts │ └── mapbox-header │ │ └── mapbox-header.component.html ├── package.json ├── CHANGELOG.md └── vue │ └── install.ts ├── tsconfig.json ├── tsconfig.vue3.json ├── .npmrc ├── .gitmodules ├── mapbox_config.ts ├── .prettierrc.js ├── svelte.config.js ├── lerna.json ├── .gitignore ├── .vscode └── settings.json └── package.json /references.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [farfromrefug] 2 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - packages/* 3 | - demo-* -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | package-lock.json 2 | node_modules/ 3 | plugin/ 4 | docs/ 5 | -------------------------------------------------------------------------------- /packages/ui-mapbox/.npmignore: -------------------------------------------------------------------------------- 1 | *.map 2 | *.ts 3 | !*.d.ts 4 | tsconfig.json 5 | references.d.ts 6 | -------------------------------------------------------------------------------- /images/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativescript-community/ui-mapbox/HEAD/images/preview.png -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | compressionLevel: mixed 2 | 3 | nmHoistingLimits: workspaces 4 | 5 | nodeLinker: node-modules 6 | -------------------------------------------------------------------------------- /images/mapbox_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativescript-community/ui-mapbox/HEAD/images/mapbox_logo.png -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "readme": true, 3 | "angular": false, 4 | "demos": [ 5 | "ng" 6 | ] 7 | } -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import defaultConfig from './tools/eslint.config.mjs'; 2 | 3 | export default defaultConfig; 4 | -------------------------------------------------------------------------------- /images/ios-xml-declared.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativescript-community/ui-mapbox/HEAD/images/ios-xml-declared.png -------------------------------------------------------------------------------- /images/ios-demoapp-slice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativescript-community/ui-mapbox/HEAD/images/ios-demoapp-slice.png -------------------------------------------------------------------------------- /packages/ui-mapbox/nativescript.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | ios: { 3 | SPMPackages: [ 4 | 5 | ], 6 | }, 7 | } -------------------------------------------------------------------------------- /src/ui-mapbox/typings/Mapbox.ios.d.ts: -------------------------------------------------------------------------------- 1 | 2 | declare class MapView extends UIView { 3 | } 4 | 5 | declare class MapboxMap extends NSObject { 6 | } 7 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /demo-snippets/ng/mapbox-token.ts: -------------------------------------------------------------------------------- 1 | export const MAPBOX_ACCESS_TOKEN = 'sk.eyJ1IjoiYWt5bGFzIiwiYSI6ImNtaGE5bzNhYzA2d3oyanNkenpmc3hrMXQifQ.YD-yEwSOtf85XnfH3Ku0OQ'; 2 | -------------------------------------------------------------------------------- /packages/ui-mapbox/platforms/ios/Resources/default_pin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativescript-community/ui-mapbox/HEAD/packages/ui-mapbox/platforms/ios/Resources/default_pin.png -------------------------------------------------------------------------------- /src/ui-mapbox/expression/expression-parser.d.ts: -------------------------------------------------------------------------------- 1 | export declare class ExpressionParser { 2 | static parseJson(json: any[]): any; 3 | static toJson(filter: any): any[]; 4 | } 5 | -------------------------------------------------------------------------------- /src/ui-mapbox/layers/parser/property-parser.d.ts: -------------------------------------------------------------------------------- 1 | export declare class PropertyParser { 2 | // static parsePropertiesForLayer(propertiesObject: any): any; 3 | static propertyValueFromLayer(layer, key: string): any; 4 | } 5 | -------------------------------------------------------------------------------- /demo-snippets/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "@nativescript-community/template-snippet", 4 | "version": "0.0.1", 5 | "dependencies": { 6 | "@nativescript-community/ui-mapbox": "*" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tools/tsconfig", 3 | "compilerOptions": { 4 | "paths": { 5 | "@nativescript-community/ui-mapbox": ["src/ui-mapbox"], 6 | "@nativescript-community/ui-mapbox/*": ["src/ui-mapbox/*"] 7 | }, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tsconfig.vue3.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "composite": true, 5 | "paths": { 6 | "nativescript-vue": ["./node_modules/nativescript-vue3"] 7 | } 8 | }, 9 | "include": [ 10 | "./demo-snippets/vue3" 11 | ] 12 | } -------------------------------------------------------------------------------- /packages/ui-mapbox/platforms/ios/Podfile: -------------------------------------------------------------------------------- 1 | # see https://github.com/CocoaPods/CocoaPods/issues/11867 for why i use podspec 2 | # pod 'Mapbox-iOS-SDK', :podspec => 'https://raw.githubusercontent.com/nativescript-community/mapbox-gl-native-ios/refs/heads/main/Mapbox-iOS-SDK.podspec' 3 | platform :ios, '14.0' 4 | pod 'MapboxMaps', '11.16.0' -------------------------------------------------------------------------------- /packages/ui-mapbox/platforms/android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | shamefully-hoist=true 2 | public-hoist-pattern[]=*eslint* 3 | public-hoist-pattern[]=source-map-support 4 | public-hoist-pattern[]=ts-patch 5 | public-hoist-pattern[]=typescript 6 | public-hoist-pattern[]=cpy-cli 7 | strict-peer-dependencies=false 8 | shell-emulator=true 9 | auto-install-peers=false 10 | loglevel=error 11 | engine-strict=true 12 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools"] 2 | path = tools 3 | url = https://github.com/nativescript-community/plugin-seed-tools.git 4 | [submodule "demo-ng"] 5 | path = demo-ng 6 | url = https://github.com/nativescript-community/plugin-seed-demo-ng.git 7 | [submodule "demo-vue"] 8 | path = demo-vue 9 | url = git@github.com:nativescript-community/plugin-seed-demo-vue.git 10 | -------------------------------------------------------------------------------- /demo-snippets/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [6.2.20](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.19...v6.2.20) (2023-09-06) 7 | 8 | **Note:** Version bump only for package @nativescript-community/template-snippet 9 | -------------------------------------------------------------------------------- /mapbox_config.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Config settings 3 | * 4 | * Set the Mapbox style and access token here. 5 | */ 6 | 7 | export const SETTINGS: any = { 8 | mapbox_access_token: 'YOUR_ACCESS_TOKEN', 9 | 10 | // The style here can either be one of the standard mapbox styles or it can be a URL pointing to self hosted tile server. 11 | 12 | mapbox_style: 'light', 13 | }; 14 | 15 | // END 16 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: ['prettier-plugin-svelte'], 3 | overrides: [{ files: '*.svelte', options: { parser: 'svelte' } }], 4 | printWidth: 200, 5 | semi: true, 6 | tabWidth: 4, 7 | trailingComma: 'none', 8 | singleQuote: true, 9 | svelteSortOrder: 'options-styles-scripts-markup', 10 | svelteStrictMode: false, 11 | svelteBracketNewLine: false, 12 | svelteIndentScriptAndStyle: true 13 | }; 14 | -------------------------------------------------------------------------------- /packages/ui-mapbox/platforms/ios/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MGLMapboxMetricsEnabledSettingShownInApp 6 | 7 | NSLocationWhenInUseUsageDescription 8 | We use your location to show where you are on the map in our app. 9 | 10 | -------------------------------------------------------------------------------- /svelte.config.js: -------------------------------------------------------------------------------- 1 | const sveltePreprocess = require('svelte-preprocess'); 2 | // const svelteNativePreprocessor = require('svelte-native-preprocessor'); 3 | 4 | module.exports = { 5 | compilerOptions: { 6 | namespace: 'foreign' 7 | }, 8 | preprocess: [ 9 | sveltePreprocess({ 10 | typescript: { 11 | compilerOptions: { 12 | target: 'es2020' 13 | } 14 | } 15 | }) 16 | // svelteNativePreprocessor() 17 | ] 18 | }; 19 | -------------------------------------------------------------------------------- /demo-snippets/vue/install.ts: -------------------------------------------------------------------------------- 1 | import { Trace } from '@nativescript/core'; 2 | import Vue from 'nativescript-vue'; 3 | import Basic from './Basic.vue'; 4 | import { MapboxTraceCategory, MapboxView } from '@nativescript-community/ui-mapbox'; 5 | 6 | export function installPlugin() { 7 | Vue.registerElement('MapboxView', () => MapboxView); 8 | } 9 | 10 | export const demos = [{ name: 'Basic', path: 'Basic', component: Basic }]; 11 | 12 | Trace.addCategories(MapboxTraceCategory); 13 | // Trace.addCategories(Trace.categories.Layout); 14 | Trace.enable(); 15 | -------------------------------------------------------------------------------- /packages/ui-mapbox/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "../../src/ui-mapbox", 5 | "outDir": "./", 6 | "paths": { 7 | "tns-core-modules": ["./node_modules/@nativescript/core"], 8 | "tns-core-modules/*": ["./node_modules/@nativescript/core/*"] 9 | } 10 | }, 11 | "include": ["../../src/ui-mapbox/**/*.ts", "../../references.d.ts", "../../tools/references.d.ts", "../../src/references.d.ts"], 12 | "exclude": ["../../src/ui-mapbox/angular/**"] 13 | } -------------------------------------------------------------------------------- /demo-snippets/ng/mapbox-demo2/mapbox-demo2.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /demo-snippets/ng/mapbox-demo3/mapbox-demo3.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/assets/hierarchy.js: -------------------------------------------------------------------------------- 1 | window.hierarchyData = "eJydlV9P2zAUxb+Ln82Infpf3hiTJiGgEki8TDyY9hYiUruyjdiE+t0nx1txaGkcXhIpOT6/e0984zfkrA0eNb8Y51iSGsuaYVlXmBDKsagZ5lLcY+Rg1cEitNZ41LyhWbwYvQbUoCu9ebC/71p4RRg9t2aJGkIlRi+uQw1adNp78Kfvqm9PYd0hnN6gBgW/PInLTtKDLUaUyT3/ce9xX8Z55nupw6V53PlSxv/7tiaAW+kF+NMk+tR6p4wvn9pu6cDEMBXFvKL3kaloxryFcA5xzXyTsjxO/ygvqGOLEa/oXnxX2j2DG8Hl0kKUFHl39sX1URztqRdNTZSrCnMlsahETJWrKuPeaB/AFdFzaWGLKt+Md7AItgyVS8tQosrT/An24nZ+XcQaaAthNctg89Wqaw3cwGNrzQhsoJ36IQUj8QMKRjL6D/tqOquXA+eyETm2tCwISerBX+EPuHO7Xo/GkCmnhkCEUjEFWVd7k5oczzZt0bDu1JNLIGmS5GAbJNNS+BewlMlIjfRPOh//0Y9knh4cplJ+8OAqbfifdnLWNek3fbwf5KeOvmsPZUfou35KCoTNUhlsdriM8gKmomc9Vyj1cdKO4XrB2Km+3f4FhQ3eyA==" -------------------------------------------------------------------------------- /packages/ui-mapbox/platforms/android/buildscript.gradle: -------------------------------------------------------------------------------- 1 | repositories { 2 | mavenCentral() 3 | def MAPBOX_DOWNLOADS_TOKEN = "$System.env.MAPBOX_DOWNLOADS_TOKEN" 4 | maven { 5 | url 'https://api.mapbox.com/downloads/v2/releases/maven' 6 | authentication { 7 | basic(BasicAuthentication) 8 | } 9 | credentials { 10 | // Do not change the username below. 11 | // This should always be `mapbox` (not your username). 12 | username = 'mapbox' 13 | // Use the secret token you stored in gradle.properties as the password 14 | password = MAPBOX_DOWNLOADS_TOKEN 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /demo-snippets/ng/basic-map/basic-map.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { RouterExtensions } from '@nativescript/angular'; 3 | import { MAPBOX_ACCESS_TOKEN } from '../mapbox-token'; 4 | 5 | @Component({ 6 | selector: 'ns-basic-map', 7 | templateUrl: './basic-map.component.html' 8 | }) 9 | export class BasicMapComponent implements OnInit { 10 | constructor(private router: RouterExtensions) {} 11 | MAPBOX_ACCESS_TOKEN = MAPBOX_ACCESS_TOKEN; 12 | 13 | ngOnInit(): void {} 14 | 15 | goBack(): void { 16 | this.router.back(); 17 | } 18 | 19 | onMapReady(args: any): void { 20 | console.log('map is ready'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ui-mapbox/layers/layer-factory.d.ts: -------------------------------------------------------------------------------- 1 | import { LayerCommon, LayerType } from '../common'; 2 | 3 | declare class LayerFactory { 4 | static createLayer(style, source): Promise; 5 | static applyLayerProperties(layer: any, properties: Record); 6 | } 7 | 8 | export declare class Layer implements LayerCommon { 9 | id: string; 10 | private instance; 11 | constructor(instance: any); 12 | visibility(): boolean; 13 | show(): void; 14 | hide(): void; 15 | getNativeInstance(): any; 16 | setFilter(filter: any[]): void; 17 | getFilter(): any[]; 18 | setProperty(name: string, value: any): void; 19 | getProperty(name: string): any; 20 | type(): LayerType; 21 | } 22 | -------------------------------------------------------------------------------- /src/ui-mapbox/README.md: -------------------------------------------------------------------------------- 1 | # iOS builds errors 2 | 3 | If you get can't find symbol MGLMapView and the like remove node_modules and platforms 4 | from your project and rebuild. 5 | 6 | For reasons I have yet to figure out, linking to the src directory from a 7 | project's package.json cause all kinds of errors. 8 | 9 | So build the plugin from the src directory using 10 | 11 | ``` 12 | npm run build.dist 13 | ``` 14 | 15 | and the reference 16 | 17 | ``` 18 | file:/nativescript-mapbox-fbs/publish/dist/package 19 | ``` 20 | 21 | in your project's package.json. 22 | 23 | # Typings 24 | 25 | When upgrading the underlying libraries the typings have to be re-generated. 26 | 27 | Remember to update the pod respositories list in case it's unable to find the 28 | updated pod file. 29 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "7.0.12", 3 | "$schema": "node_modules/@lerna-lite/cli/schemas/lerna-schema.json", 4 | "packages": [ 5 | "packages/*" 6 | ], 7 | "npmClient": "yarn", 8 | "useWorkspaces": true, 9 | "command": { 10 | "publish": { 11 | "cleanupTempFiles": true 12 | } 13 | }, 14 | "npmClientArgs": [ 15 | "--no-package-lock" 16 | ], 17 | "commitHooks": false, 18 | "createRelease": "github", 19 | "conventionalCommits": true, 20 | "private": false, 21 | "message": "chore(release): publish new version %v", 22 | "changelogPreset": "conventional-changelog-conventionalcommits", 23 | "ignoreChanges": [ 24 | "**/__fixtures__/**", 25 | "**/__tests__/**", 26 | "**/*.md" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /src/ui-mapbox/expression/expression-parser.android.ts: -------------------------------------------------------------------------------- 1 | const Expression = com.mapbox.maps.extension.style.expressions.generated.Expression; 2 | 3 | export class ExpressionParser { 4 | static parseJson(json: any[]): com.mapbox.maps.extension.style.expressions.generated.Expression { 5 | const expression = Expression.fromRaw(JSON.stringify(json)); 6 | return expression; 7 | } 8 | static toJson(filter: com.mapbox.maps.extension.style.expressions.generated.Expression): any[] { 9 | if (!filter) { 10 | return null; 11 | } 12 | 13 | if (!(filter instanceof com.mapbox.maps.extension.style.expressions.generated.Expression)) { 14 | throw new Error('Filter must be a Expression.'); 15 | } 16 | 17 | return JSON.parse(filter.toJson()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /demo-snippets/ng/basic-map/basic-map.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /demo-snippets/ng/mapbox-footer/mapbox-footer.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, NO_ERRORS_SCHEMA, inject } from '@angular/core'; 2 | import { RouterExtensions } from '@nativescript/angular'; 3 | 4 | @Component({ 5 | selector: 'app-mapbox-footer', 6 | template: ` 7 | Goto Mapbox 8 | Goto Mapbox 2 9 | Goto Mapbox 3 module 10 | `, 11 | schemas: [NO_ERRORS_SCHEMA] 12 | }) 13 | export class MapboxFooterComponent { 14 | router: RouterExtensions = inject(RouterExtensions); 15 | 16 | goToMapbox(route: string) { 17 | this.router.navigate([route]).then((r) => { 18 | console.log(`Navigation to ${route} successful: `, r); 19 | }); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /demo-snippets/ng/mapbox-demo3/mapbox-demo3.module.ts: -------------------------------------------------------------------------------- 1 | import { MapboxDemo3Component } from './mapbox-demo3.component'; 2 | import { NO_ERRORS_SCHEMA, NgModule } from '@angular/core'; 3 | import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular'; 4 | import { Routes } from '@angular/router'; 5 | 6 | import { MapboxHeaderComponent } from '../mapbox-header/mapbox-header.component'; 7 | import { MAPBOX_ACCESS_TOKEN } from '../mapbox-token'; 8 | import { MapboxFooterComponent } from '../mapbox-footer/mapbox-footer.component'; 9 | 10 | const routes: Routes = [{ path: '', component: MapboxDemo3Component }]; 11 | 12 | @NgModule({ 13 | declarations: [MapboxDemo3Component], 14 | imports: [NativeScriptCommonModule, NativeScriptRouterModule.forChild(routes), MapboxHeaderComponent, MapboxFooterComponent], 15 | exports: [NativeScriptCommonModule], 16 | providers: [], 17 | schemas: [NO_ERRORS_SCHEMA] 18 | }) 19 | export class MapboxDemo3Module {} 20 | -------------------------------------------------------------------------------- /packages/ui-mapbox/platforms/android/res/drawable/ic_red_marker.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 13 | 16 | 17 | -------------------------------------------------------------------------------- /src/ui-mapbox/references.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | 5 | /// 6 | /// 7 | /// 8 | 9 | // declare namespace com { 10 | // export namespace mapbox { 11 | // export namespace maps { 12 | // interface MapboxMap extends plugin.animation.CameraAnimationsPlugin, plugin.annotation.AnnotationPlugin {} 13 | // interface Style extends extension.style.StyleContract.StyleExtension {} 14 | // } 15 | // } 16 | // } 17 | // declare namespace com { 18 | // export namespace mapbox { 19 | // export namespace maps { 20 | // interface MapboxOptions extends common.MapboxOptions {} 21 | // } 22 | // } 23 | // } 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # NativeScript 2 | hooks/ 3 | node_modules/ 4 | platforms 5 | 6 | # NativeScript Template 7 | *.js.map 8 | !ngcc.config.js 9 | !webpack.config.js 10 | 11 | # Logs 12 | logs 13 | *.log 14 | npm-debug.log* 15 | yarn-debug.log* 16 | yarn-error.log* 17 | 18 | # General 19 | .DS_Store 20 | .AppleDouble 21 | .LSOverride 22 | .idea 23 | .cloud 24 | .gradle 25 | .project 26 | .yarn 27 | .cxx 28 | tmp/ 29 | 30 | !.eslintrc.js 31 | !.prettierrc.js 32 | 33 | !e2e/*.js 34 | !detox.config.js 35 | devices.js 36 | 37 | *.framework 38 | *.xcframework 39 | **/*.js.map 40 | src/**/*.js 41 | packages/**/*.js 42 | packages/**/*.d.ts 43 | bin 44 | build 45 | Pods 46 | !packages/*/platforms 47 | /packages/**/*.aar 48 | /packages/**/*.framework 49 | /packages/**/*.xcframework 50 | /demo-snippets/**/*.aar 51 | *.xcuserdatad 52 | /packages/README.md 53 | packages/**/*js.map 54 | packages/**/*js 55 | packages/typings 56 | packages/**/angular 57 | packages/**/*.ngsummary.json 58 | packages/**/*.metadata.json 59 | 60 | /blueprint.md 61 | 62 | *.tsbuildinfo -------------------------------------------------------------------------------- /demo-snippets/ng/mapbox-demo/mapbox-demo.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/ui-mapbox/geo.utils.ts: -------------------------------------------------------------------------------- 1 | export class GeoUtils { 2 | /** 3 | * Is the current location within the given circle? 4 | * 5 | * @param {number} longitude to check 6 | * @param {number} latitude to check 7 | * @param {number} longitude center of circle 8 | * @param {number} latitude center of circle 9 | * @param {number} radius of circle in meters 10 | * 11 | * @return {boolean} true if the point is within the given geofence. 12 | * 13 | * @link https://stackoverflow.com/questions/24680247/check-if-a-latitude-and-longitude-is-within-a-circle-google-maps 14 | */ 15 | 16 | static isLocationInCircle(lng, lat, circleLng, circleLat, circleRadius) { 17 | const ky = 40000 / 360; 18 | const kx = Math.cos((Math.PI * circleLat) / 180.0) * ky; 19 | const dx = Math.abs(circleLng - lng) * kx; 20 | const dy = Math.abs(circleLat - lat) * ky; 21 | 22 | const distance = Math.sqrt(dx * dx + dy * dy); 23 | 24 | if (distance < circleRadius / 1000) { 25 | return true; 26 | } 27 | 28 | return false; 29 | } 30 | } // END 31 | -------------------------------------------------------------------------------- /docs/assets/navigation.js: -------------------------------------------------------------------------------- 1 | window.navigationData = "eJyN2E1z2zYQBuD/wrOnatwmbX1z1CQzHalWJTuHZnKAyTWFMYjlAGBstpP/noFISQAF7PLKffcBSIKfX/4vHLy64qZYrrC+71uwxVXRCrcvbgrQXWMXp8JPe9eo4qp4lroqbn7/fnXuRe0Mqg1a6STqCyEu5521aHeuVzAFjtvznR9eWwPWStQbYSyYs1AqYS3YxTQRW2+uQ+0T4IOTyl4qxwrVvRJ9agKHzWzfR1E6NH2mfaxSylq0j/h62T9s5zuX2DThKYz7hyqvfJbwkjN8bZ7wXligFF+fJw3z5rxzilI3Blswrs+ttLhOSbdV9eHVmc6vyrvWXxvBkpPagXkSJdhFIhez12/fxewnwL8s6qXqrAMDFaNn4swghyXJyGGG4Tao+po9EHFqBqmkhhlmECNRLRvhYCkaMIJkE0EKfo+drtLUUKKa/wQFDu6envxebKFm1lM+Tg6CL1qhqOYPQzTMGWhjsPb3bBI/hijwIwjXGUg6Y41q91fH7u7vHXamTCNRgqJWwq10nTSGEt3cg5nenyPhVCcZaV10Six1ErNpaojhlnrbyiR5qvLEeEcimDExgzocGHpOpwzPrYV5Jic2BHjIP3joWY0JiorOUJKKEhT1Twem34Ku/INgvDrIFUI1sAMNl8zsYZJxapCt8KuDuHTDAAXtwC3Bt1FznIYY8F4qx3BBhMH8KmnRcOAkxqD/IjYr+AaKUac5kt3jC8md6zOZtTC15LUxxqFbsJ1yWWwok0h+tfHr7N6I8vnB0utsGqJAH1thKVzuzhAGKOgz+I8PYufCAAmNSzCNjEXmzW4Y5eIYOf+hupjWJ9bPf/z25u319MHqv3Gn0KnACbuu9ZOGKktdJjjzoa2EA3JHExFWDc728HK6xupitunUHPuwNKWuc2pY5zxRlmDtPT6DPn5UnclvwkjxqMAuErFY/iVCnTPysfN7dvwjQeL5ODGI/2mS0vx2oq3EphXWzplXJkrgFSjRU2QUoCBpfcMWneBmmYny+K40qNQMOg7ysH+gzmDDGI/6x98MNIwR6F5WcBssOwLORBl8Oa4dBp7EGHSFNXJimCE4JZx0XQUUN81Q3PFGhk2LGvTx3YfkmR5yuBrnXMGpHMnqmj8q0xABDh8X/n4MS+Ggjn47nslEjEAb0W5BVOR9ZpqhucOfX4aLMgRn9/gSPtooNpcleAcKGnCG3PuLEAH+d3ytpsCLEHUAwK2wPqTP1FOny8PiXgTlGHn36/evPwDYondG" -------------------------------------------------------------------------------- /src/ui-mapbox/markers/Marker.common.ts: -------------------------------------------------------------------------------- 1 | import { Application, Color, Label, StackLayout, Utils } from '@nativescript/core'; 2 | const MARKER_PADDING_PX = 10; 3 | 4 | export function createInfoWindowView(title, snippet) { 5 | const view = new StackLayout(); 6 | view.className = 'mapbox-info-window'; 7 | view.padding = MARKER_PADDING_PX; 8 | view.backgroundColor = 'white'; 9 | view.width = 'auto'; // WRAP_CONTENT 10 | view.height = 'auto'; // WRAP_CONTENT 11 | view.borderRadius = 12; 12 | view.color = new Color('#555'); 13 | view['shadowColor'] = '#000'; 14 | view['shadowOpacity'] = 0.25; 15 | view['shadowRadius'] = 8; 16 | 17 | const titleLabel = new Label(); 18 | titleLabel.id = 'title'; 19 | titleLabel.text = title; 20 | titleLabel.className = 'mapbox-info-window-title'; 21 | titleLabel.fontSize = 16; 22 | titleLabel.fontWeight = 'bold'; 23 | view.addChild(titleLabel); 24 | 25 | const subtitle = new Label(); 26 | subtitle.id = 'subtitle'; 27 | subtitle.text = snippet; 28 | subtitle.className = 'mapbox-info-window-snippet'; 29 | subtitle.fontSize = 14; 30 | // subtitle.visibility = snippet ? 'visible' : 'collapse'; 31 | subtitle.color = new Color('#555'); 32 | view.addChild(subtitle); 33 | 34 | return view; 35 | } 36 | -------------------------------------------------------------------------------- /src/ui-mapbox/expression/expression-parser.ios.ts: -------------------------------------------------------------------------------- 1 | // src/ui-mapbox/expression-parser.ios.ts 2 | // TypeScript shim that exports ExpressionParser (TS API) while delegating to native NativeExpressionParser when available. 3 | 4 | export class ExpressionParser { 5 | // Return native predicate object (opaque) if native parser available, otherwise return the expression JSON. 6 | static parseJson(json: any[]): any { 7 | try { 8 | if ((global as any).NativeExpressionParser && (global as any).NativeExpressionParser.parseJson) { 9 | const res = (global as any).NativeExpressionParser.parseJson(json); 10 | if (res) return res; 11 | } 12 | } catch (e) { 13 | // ignore and fallback 14 | } 15 | return json; 16 | } 17 | 18 | // Try to convert native predicate back to JSON expression. Returns array or null. 19 | static toJson(filter: any): any[] | null { 20 | try { 21 | if (!filter) return null; 22 | if (Array.isArray(filter)) return filter; 23 | if ((global as any).NativeExpressionParser && (global as any).NativeExpressionParser.toJson) { 24 | const res = (global as any).NativeExpressionParser.toJson(filter); 25 | if (res) return res; 26 | } 27 | } catch (e) { 28 | // ignore 29 | } 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /demo-snippets/ng/install.module.ts: -------------------------------------------------------------------------------- 1 | import { NO_ERRORS_SCHEMA, NgModule } from '@angular/core'; 2 | 3 | import { registerElement } from '@nativescript/angular'; 4 | registerElement('Mapbox', () => require('@nativescript-community/ui-mapbox').MapboxView); 5 | 6 | import { BasicMapComponent } from './basic-map/basic-map.component'; 7 | 8 | import { MapboxDemoComponent } from './mapbox-demo/mapbox-demo.component'; 9 | import { MapboxDemo2Component } from './mapbox-demo2/mapbox-demo2.component'; 10 | import { Trace } from '@nativescript/core'; 11 | import { MapboxTraceCategory } from '@nativescript-community/ui-mapbox'; 12 | 13 | export const COMPONENTS = [BasicMapComponent, MapboxDemoComponent, MapboxDemo2Component]; 14 | @NgModule({ 15 | imports: [], 16 | exports: [], 17 | schemas: [NO_ERRORS_SCHEMA] 18 | }) 19 | export class InstallModule {} 20 | 21 | export function installPlugin() {} 22 | 23 | export const demos = [ 24 | { name: 'Basic Map', path: 'basic-map', component: BasicMapComponent }, 25 | { name: 'Demo1', path: 'demo-map', component: MapboxDemoComponent }, 26 | { name: 'Demo2', path: 'demo2-map', component: MapboxDemo2Component } 27 | // { 28 | // path: 'mapbox3', 29 | // loadChildren: () => import('./mapbox-demo3/mapbox-demo3.module').then((m) => m.MapboxDemo3Module) 30 | // } 31 | ]; 32 | 33 | Trace.addCategories(MapboxTraceCategory); 34 | // Trace.addCategories(Trace.categories.Layout); 35 | Trace.enable(); 36 | -------------------------------------------------------------------------------- /packages/ui-mapbox/platforms/ios/src/NativeExpressionParser.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import MapboxMaps 3 | 4 | @objcMembers 5 | public class NativeExpressionParser: NSObject { 6 | 7 | /// Parse a Mapbox-style expression provided as a JSON string into a native Expression instance. 8 | /// - Parameter jsonString: NSString containing the JSON array for the expression (e.g. '["==", ["get","foo"], "bar"]') 9 | /// - Returns: an opaque native Expression (as Any) on success, or nil on failure. 10 | @objc public static func parseJson(_ jsonString: NSString) -> Any? { 11 | // Convert string -> Data -> JSON object (NSArray expected) 12 | guard let data = (jsonString as String).data(using: .utf8) else { return nil } 13 | do { 14 | return try JSONDecoder().decode(Exp.self, from: data) 15 | } catch { 16 | // parsing or Expression init failed 17 | return nil 18 | } 19 | } 20 | 21 | /// Convert a native Expression (opaque) back into a JSON string. 22 | /// - Parameter expression: the native Expression (as returned by parseJson) or nil 23 | /// - Returns: NSString containing the JSON array representation, or nil on failure. 24 | @objc public static func toJson(_ expression: Any?) -> NSString? { 25 | guard let expr = expression as? Exp else { return nil } 26 | do { 27 | let data = try JSONEncoder().encode(expr) 28 | return String(data: data, encoding: .utf8) as NSString? 29 | } catch { 30 | return nil 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /demo-snippets/ng/mapbox-header/mapbox-header.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib", 3 | "svelte.plugin.svelte.compilerWarnings": { 4 | "missing-declaration": "ignore", 5 | "a11y-aria-attributes": "ignore", 6 | "a11y-incorrect-aria-attribute-type": "ignore", 7 | "a11y-unknown-aria-attribute": "ignore", 8 | "a11y-hidden": "ignore", 9 | "a11y-misplaced-role": "ignore", 10 | "a11y-unknown-role": "ignore", 11 | "a11y-no-abstract-role": "ignore", 12 | "a11y-no-redundant-roles": "ignore", 13 | "a11y-role-has-required-aria-props": "ignore", 14 | "a11y-accesskey": "ignore", 15 | "a11y-autofocus": "ignore", 16 | "a11y-misplaced-scope": "ignore", 17 | "a11y-positive-tabindex": "ignore", 18 | "a11y-invalid-attribute": "ignore", 19 | "a11y-missing-attribute": "ignore", 20 | "a11y-img-redundant-alt": "ignore", 21 | "a11y-label-has-associated-control": "ignore", 22 | "a11y-media-has-caption": "ignore", 23 | "a11y-distracting-elements": "ignore", 24 | "a11y-structure": "ignore", 25 | "a11y-mouse-events-have-key-events": "ignore", 26 | "a11y-missing-content": "ignore", 27 | "illegal-attribute-character": "ignore" 28 | }, 29 | "scss.lint.validProperties": [ 30 | "max-font-size", 31 | "min-font-size", 32 | "ios-a11y-adjusts-font-size", 33 | "status-bar-style", 34 | "navigation-bar-color", 35 | "status-bar-color", 36 | "ripple-color", 37 | "stroke-color", 38 | "fill-color", 39 | "on-check-color", 40 | "on-tint-color", 41 | "shape", 42 | "elevation", 43 | "horizontal-align", 44 | "horizontal-alignment", 45 | "vertical-text-alignment", 46 | "floating", 47 | "vertical-alignment", 48 | "placeholder-color", 49 | "variant" 50 | ] 51 | } -------------------------------------------------------------------------------- /src/ui-mapbox/layers/parser/property-parser.ios.ts: -------------------------------------------------------------------------------- 1 | import { Color } from '@nativescript/core'; 2 | 3 | export class PropertyParser { 4 | // static parsePropertiesForLayer(propertiesObject) { 5 | // const nProperties = {}; 6 | // if (propertiesObject) { 7 | // Object.keys(propertiesObject).forEach((k) => { 8 | // const actualKey = keysMap[k] || toCamelCase(k); 9 | // const value = propertiesObject[k]; 10 | // const rValue = transformValue(k, value, styleExtras[k]?.iosType); 11 | // if (Array.isArray(value)) { 12 | // nProperties[actualKey] = (NSExpression as any).expressionWithMGLJSONObject(rValue); 13 | // } else { 14 | // nProperties[actualKey] = NSExpression.expressionForConstantValue(rValue); 15 | // } 16 | // }); 17 | // } 18 | // return nProperties; 19 | // } 20 | // static propertyValueFromLayer(layer, key: string): any { 21 | // const actualKey = keysMap[key] || toCamelCase(key); 22 | // const nValue: NSExpression = layer[actualKey]; 23 | // if (!nValue) { 24 | // return null; 25 | // } 26 | // if (nValue.expressionType === NSExpressionType.ConstantValueExpressionType) { 27 | // if (nValue.constantValue instanceof UIColor) { 28 | // return Color.fromIosColor(nValue.constantValue); 29 | // } else { 30 | // return nValue.constantValue; 31 | // } 32 | // } else { 33 | // const expressionObj = (nValue as any).mgl_jsonExpressionObject; 34 | // const data = NSJSONSerialization.dataWithJSONObjectOptionsError(expressionObj, 0 as any); 35 | // const expression: any = NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding); 36 | // return JSON.parse(expression); 37 | // } 38 | // } 39 | } 40 | -------------------------------------------------------------------------------- /demo-snippets/ng/mapbox-demo/mapbox-demo.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, NO_ERRORS_SCHEMA, OnDestroy, OnInit, inject } from '@angular/core'; 2 | import { ActionBarComponent, NavigationButtonDirective, RouterExtensions, registerElement } from '@nativescript/angular'; 3 | import { LatLng, MapboxApi, MapboxTraceCategory, MapboxView, MapboxViewApi } from '@nativescript-community/ui-mapbox'; 4 | import { Trace } from '@nativescript/core'; 5 | import { MapboxHeaderComponent } from '../mapbox-header/mapbox-header.component'; 6 | import { MAPBOX_ACCESS_TOKEN } from '../mapbox-token'; 7 | import { MapboxFooterComponent } from '../mapbox-footer/mapbox-footer.component'; 8 | 9 | registerElement('Mapbox', () => require('@nativescript-community/ui-mapbox').MapboxView); 10 | 11 | @Component({ 12 | selector: 'app-mapbox-demo', 13 | templateUrl: './mapbox-demo.component.html', 14 | schemas: [NO_ERRORS_SCHEMA], 15 | imports: [ActionBarComponent, NavigationButtonDirective, MapboxHeaderComponent, MapboxFooterComponent] 16 | }) 17 | export class MapboxDemoComponent implements OnInit, OnDestroy { 18 | router: RouterExtensions = inject(RouterExtensions); 19 | 20 | mapboxView: MapboxView | undefined; 21 | mapbox: MapboxApi | undefined; 22 | 23 | MAPBOX_ACCESS_TOKEN = MAPBOX_ACCESS_TOKEN; 24 | 25 | ngOnInit() { 26 | console.log('MapboxDemoComponent initialized'); 27 | Trace.addCategories(MapboxTraceCategory); 28 | // Trace.enable() 29 | } 30 | 31 | goBack(): void { 32 | this.router.back(); 33 | } 34 | 35 | onMapReady(args: any): void { 36 | console.log('map is ready: ', args.map); 37 | 38 | this.mapboxView = args.map; 39 | this.mapbox = this.mapboxView?.getMapboxApi(); 40 | 41 | console.log('mapboxView map is ready:', this.mapboxView); 42 | } 43 | 44 | ngOnDestroy(): void { 45 | if (this.mapbox) { 46 | this.mapbox.destroy(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/ui-mapbox/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@nativescript-community/ui-mapbox", 3 | "version": "7.0.12", 4 | "description": "Interactive, thoroughly customizable maps powered by vector tiles and OpenGL.", 5 | "main": "index", 6 | "typings": "index.d.ts", 7 | "scripts": { 8 | "build": "npm run tsc && npm run readme", 9 | "readme": "readme generate -c ../../tools/readme/blueprint.json", 10 | "tsc": "cpy '**/*.d.ts' '../../packages/ui-mapbox' --parents --cwd=../../src/ui-mapbox && tsc --build", 11 | "clean": "bin/rimraf ./*.d.ts ./*.js ./*.js.map ./*.tsbuildinfo ./*.mjs ./*.mjs.map ./angular ./svelte ./vue* ./react", 12 | "build.all": "npm run build" 13 | }, 14 | "nativescript": { 15 | "platforms": { 16 | "android": "3.0.0", 17 | "ios": "3.0.0" 18 | } 19 | }, 20 | "keywords": [ 21 | "NativeScript", 22 | "Map", 23 | "Maps", 24 | "Native Maps", 25 | "Mapbox", 26 | "iOS", 27 | "Android", 28 | "Angular", 29 | "preview|https://raw.githubusercontent.com/nativescript-community/ui-mapbox/master/images/preview.png" 30 | ], 31 | "author": { 32 | "name": "Yermo Lamers", 33 | "email": "yml@yml.com", 34 | "url": "https://miles-by-motorcycle.com/flyingbricksoftware/about" 35 | }, 36 | "contributors": [ 37 | { 38 | "name": "Eddy Verbruggen - Original Author", 39 | "email": "eddyverbruggen@gmail.com" 40 | }, 41 | { 42 | "name": "Alex Wells", 43 | "email": "autaut03@gmail.com" 44 | } 45 | ], 46 | "license": "MIT", 47 | "bugs": { 48 | "url": "https://github.com/nativescript-community/ui-mapbox/issues" 49 | }, 50 | "repository": { 51 | "type": "git", 52 | "url": "https://github.com/nativescript-community/ui-mapbox" 53 | }, 54 | "readmeFilename": "README.md", 55 | "dependencies": { 56 | "@nativescript-community/perms": "^3.0.4" 57 | }, 58 | "gitHead": "89403ea15d2e03759bdf8d04087d58236efc971a" 59 | } 60 | -------------------------------------------------------------------------------- /packages/ui-mapbox/platforms/android/include.gradle: -------------------------------------------------------------------------------- 1 | repositories { 2 | mavenCentral() 3 | def MAPBOX_DOWNLOADS_TOKEN = project.hasProperty("MAPBOX_DOWNLOADS_TOKEN") ? project.MAPBOX_DOWNLOADS_TOKEN : "$System.env.MAPBOX_DOWNLOADS_TOKEN" 4 | maven { 5 | url 'https://api.mapbox.com/downloads/v2/releases/maven' 6 | authentication { 7 | basic(BasicAuthentication) 8 | } 9 | credentials { 10 | // Do not change the username below. 11 | // This should always be `mapbox` (not your username). 12 | username = 'mapbox' 13 | // Use the secret token you stored in gradle.properties as the password 14 | password = MAPBOX_DOWNLOADS_TOKEN 15 | } 16 | } 17 | } 18 | 19 | // see https://www.mapbox.com/android-sdk/ 20 | dependencies { 21 | def mapboxVersion = project.hasProperty("mapboxVersion") ? project.mapboxVersion : "11.16.2" 22 | def mapboxServicesVersion = project.hasProperty("mapboxServicesVersion") ? project.mapboxServicesVersion : "7.8.0" 23 | def mapboxPluginsVersion = project.hasProperty("mapboxPluginsVersion") ? project.mapboxPluginsVersion : "v9" 24 | def mapboxAnnotationPluginVersion = project.hasProperty("mapboxAnnotationPluginVersion") ? project.mapboxAnnotationPluginVersion : "0.9.0" 25 | def okHttpVersion = project.hasProperty("okHttpVersion") ? project.okHttpVersion : "4.9.0" 26 | 27 | println "com.mapbox.maps:android:$mapboxVersion" 28 | 29 | // Core Mapbox Maps SDK v11+. For now use ndk27 to support 16Kb 30 | implementation "com.mapbox.maps:android-ndk27:$mapboxVersion" 31 | 32 | // GeoJSON / Annotations support (choose correct module name & version) 33 | implementation "com.mapbox.mapboxsdk:mapbox-sdk-geojson:$mapboxServicesVersion" // example version 34 | // implementation "com.mapbox.plugin:maps-annotation:$mapboxVersion" // plugin example 35 | 36 | // Additional plugins: e.g., location component, gestures, etc. 37 | // implementation "com.mapbox.plugin:maps-locationcomponent:$mapboxVersion" 38 | // implementation "com.mapbox.plugin:maps-gestures:$mapboxVersion" 39 | 40 | implementation "com.squareup.okhttp3:okhttp:$okHttpVersion" 41 | 42 | // If you need Mapbox Search or Navigation SDKs, add here 43 | // implementation "com.mapbox.search:autofill:1.0.0-beta.39" 44 | // implementation "com.mapbox.navigation:android:3.0.0" 45 | 46 | } 47 | 48 | android { 49 | compileOptions { 50 | sourceCompatibility JavaVersion.VERSION_1_8 51 | targetCompatibility JavaVersion.VERSION_1_8 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/ui-mapbox/layers/parser/property-parser.android.ts: -------------------------------------------------------------------------------- 1 | import { Color } from '@nativescript/core'; 2 | 3 | export function toCamelCase(s) { 4 | return s.replace(/([-_][a-z])/gi, ($1) => $1.toUpperCase().replace('-', '').replace('_', '')); 5 | } 6 | 7 | export function toPascalCase(s) { 8 | return s.replace(/(^[a-z]|[-_][a-z])/gi, ($1) => $1.toUpperCase().replace('-', '').replace('_', '')); 9 | } 10 | 11 | const Expression = com.mapbox.maps.extension.style.expressions.generated.Expression; 12 | export function transformValue(key, value) { 13 | let nValue = value; 14 | if (Array.isArray(value)) { 15 | nValue = Expression.fromRaw(JSON.stringify(value)); 16 | } 17 | if (key.indexOf('-color') !== -1 && !Array.isArray(value)) { 18 | const color = value instanceof Color ? value : new Color(value); 19 | nValue = color.android; 20 | } else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { 21 | nValue = Expression.literal(value as any); 22 | } else if (Array.isArray(value)) { 23 | // assume it's a JSON-style expression 24 | nValue = Expression.fromRaw(JSON.stringify(value)); 25 | } 26 | return nValue; 27 | } 28 | export class PropertyParser { 29 | // static parsePropertiesForLayer(propertiesObject) { 30 | // const nProperties = []; 31 | 32 | // const PropertyFactory = com.mapbox.maps.extension.style.layers.PropertyFactory; 33 | // if (propertiesObject) { 34 | // Object.keys(propertiesObject).forEach((k) => { 35 | // const actualKey = toCamelCase(k); 36 | // const value = propertiesObject[k]; 37 | // const nValue = transformValue(k, value); 38 | // nProperties.push(PropertyFactory[actualKey](nValue)); 39 | // }); 40 | // } 41 | 42 | // return nProperties; 43 | // } 44 | 45 | static propertyValueFromLayer(layer, key: string): any { 46 | const getterMethodName = `get${toPascalCase(key)}`; 47 | 48 | let nValue: com.mapbox.maps.extension.style.layers.properties.PropertyValue; 49 | try { 50 | nValue = layer[getterMethodName](); 51 | } catch (e) { 52 | // native method seems not exist 53 | return null; 54 | } 55 | 56 | if (nValue === null || nValue === undefined) { 57 | return null; 58 | } 59 | 60 | if (nValue.isExpression()) { 61 | return JSON.parse(nValue.toString()); 62 | } else if (!!nValue.getColorInt()) { 63 | return new Color(nValue.getColorInt().intValue()); 64 | } else { 65 | return nValue.getValue(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/ui-mapbox/layers/layer-factory.ios.ts: -------------------------------------------------------------------------------- 1 | // src/ui-mapbox/layer-factory.ios.ts 2 | // TypeScript shim that exports LayerFactory (TS API) while delegating to native NativeLayerFactory when available. 3 | // This preserves the TS export name 'LayerFactory' as requested. 4 | 5 | import { Trace } from '@nativescript/core'; 6 | import { CLog, CLogTypes, LayerCommon, LayerType } from '../common'; 7 | 8 | export class Layer implements LayerCommon { 9 | constructor( 10 | public mapboxView: MapView, 11 | public id: string 12 | ) {} 13 | 14 | visibility(): boolean { 15 | return true; 16 | } 17 | 18 | show(): void { 19 | NativeLayerFactory.setLayerVisibility(this.mapboxView, this.id, true); 20 | } 21 | 22 | hide(): void { 23 | NativeLayerFactory.setLayerVisibility(this.mapboxView, this.id, false); 24 | } 25 | 26 | getNativeInstance(): any { 27 | return null; 28 | } 29 | 30 | setFilter(filter: any[]): void { 31 | // Not implemented here - recommend using addLayer with JSON via Mapbox.addLayer 32 | } 33 | 34 | getFilter(): any[] { 35 | return null; 36 | } 37 | 38 | setProperty(name: string, value: any): void { 39 | NativeLayerFactory.setLayerProperty(this.mapboxView, this.id, name, value); 40 | } 41 | 42 | getProperty(name: string): any { 43 | return NativeLayerFactory.getLayerProperty(this.mapboxView, this.id, name); 44 | } 45 | type(): LayerType { 46 | return NativeLayerFactory.getLayerType(this.mapboxView, this.id) as LayerType; 47 | } 48 | } 49 | 50 | // Export a TS LayerFactory that matches the old TS API but delegates to NativeLayerFactory 51 | export class LayerFactory { 52 | static async createLayer(mapboxView: MapView, style: any, belowLayerId: string): Promise { 53 | const styleJson = typeof style === 'string' ? style : JSON.stringify(style); 54 | if (Trace.isEnabled()) { 55 | CLog(CLogTypes.info, 'createLayer:', belowLayerId, JSON.stringify(style)); 56 | } 57 | const id = style.id || 'layer_' + Date.now(); 58 | if (NativeLayerFactory.createLayer(mapboxView, id, styleJson, belowLayerId)) { 59 | return new Layer(mapboxView, id); 60 | } else { 61 | throw new Error('failed to create layer'); 62 | } 63 | } 64 | 65 | static applyLayerProperties(mapboxView: MapView, layer: any, properties: Record) { 66 | try { 67 | // NativeLayerFactory.applyLayerProperties(layer.id, properties); 68 | // if ((global as any).NativeLayerFactory && (global as any).NativeLayerFactory.setLayerProperty) { 69 | for (const k of Object.keys(properties)) { 70 | NativeLayerFactory.setLayerProperty(mapboxView, layer.id, k, properties[k]); 71 | } 72 | // } 73 | } catch (e) {} 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "description": "A Nativescript plugin for Mapbox Native Maps.", 4 | "scripts": { 5 | "setup": "npm run submodules && ts-patch install", 6 | "sync": "node ./tools/sync.mjs", 7 | "build": "lerna run build", 8 | "build.all": "npm run build", 9 | "clean": "rimraf -g 'packages/**/*.d.ts' 'packages/**/*.tsbuildinfo' 'packages/**/*.js' 'packages/**/*.mjs' 'packages/**/*.js.map' 'packages/**/*.mjs.map' 'packages/**/*.metada' 'packages/**/angular/ng-package.json'", 10 | "commitmsg": "commitlint -e $GIT_PARAMS", 11 | "demo.ng.android": "cd ./demo-ng && ns run android --no-hmr --env.watchNodeModules", 12 | "demo.ng.clean": "cd ./demo-ng && ns clean", 13 | "demo.ng.ios": "cd ./demo-ng && ns run ios --no-hmr --env.watchNodeModules", 14 | "publish": "npm run setup && npm run clean && npm run build.all && npm run readme && npm run doc && npm run commit_readme_doc_changes && lerna publish", 15 | "postinstall": "npm run setup", 16 | "readme": "lerna run readme && node ./tools/readme.js", 17 | "start": "./node_modules/.bin/ntl -A -s 15 -o", 18 | "submodules": "git submodule update --init", 19 | "update": "node ./tools/update.js", 20 | "doc": "node tools/builddoc.mjs", 21 | "fullclean": "npm run clean && rimraf -g 'packages/**/node_modules' 'demo-*/hooks' 'demo-*/node_modules' 'package-lock.json' 'pnpm-lock.yaml' 'node_modules'", 22 | "commit_readme_doc_changes": "git add docs/** *.md ; git commit -m \"readme/doc\" ; echo \"commit readme doc done\"" 23 | }, 24 | "repository": { 25 | "type": "git", 26 | "url": "https://github.com/nativescript-community/ui-mapbox.git" 27 | }, 28 | "license": "MIT", 29 | "bugs": { 30 | "url": "https://github.com/nativescript-community/ui-mapbox/issues" 31 | }, 32 | "homepage": "https://github.com/nativescript-community/ui-mapbox", 33 | "readmeFilename": "README.md", 34 | "dependencies": { 35 | "@nativescript-community/perms": "^3.0.4", 36 | "@nativescript-community/plugin-seed-tools": "portal:tools" 37 | }, 38 | "ntl": { 39 | "descriptions": { 40 | "build": "Build the plugin", 41 | "build.all": "Build the plugin for all platforms", 42 | "clean": "Clean the local environment.", 43 | "demo.ng.android": "Runs the Angular demo on Android.", 44 | "demo.ng.ios": "Runs the Angular demo on iOS.", 45 | "watch": "Watch for changes in the plugin source and re-build." 46 | } 47 | }, 48 | "dependenciesMeta": { 49 | "@nativescript-community/plugin-seed-tools": {} 50 | }, 51 | "engines": { 52 | "npm": "please use yarn or pnpm", 53 | "yarn": ">=1.19.1", 54 | "pnpm": ">=7.0.0", 55 | "node": "^14.20.0 || ^16.13.0 || >=18.10.0" 56 | }, 57 | "workspaces": [ 58 | "packages/*", 59 | "demo*" 60 | ], 61 | "packageManager": "yarn@4.10.2" 62 | } 63 | -------------------------------------------------------------------------------- /demo-snippets/ng/mapbox-demo3/mapbox-demo3.component.ts: -------------------------------------------------------------------------------- 1 | import { ChangeDetectorRef, Component, OnDestroy, OnInit, inject } from '@angular/core'; 2 | import { RouterExtensions, registerElement } from '@nativescript/angular'; 3 | import { MapStyle, MapboxApi, MapboxMarker, MapboxTraceCategory, MapboxView } from '@nativescript-community/ui-mapbox'; 4 | import { ContentView, EventData, Trace } from '@nativescript/core'; 5 | 6 | import { MapboxHeaderComponent } from '../mapbox-header/mapbox-header.component'; 7 | import { MAPBOX_ACCESS_TOKEN } from '../mapbox-token'; 8 | import { MapboxFooterComponent } from '../mapbox-footer/mapbox-footer.component'; 9 | 10 | registerElement('Mapbox', () => require('@nativescript-community/ui-mapbox').MapboxView); 11 | 12 | @Component({ 13 | selector: 'app-mapbox-demo3', 14 | templateUrl: './mapbox-demo3.component.html', 15 | standalone: false 16 | }) 17 | export class MapboxDemo3Component implements OnInit, OnDestroy { 18 | router: RouterExtensions = inject(RouterExtensions); 19 | cd: ChangeDetectorRef = inject(ChangeDetectorRef); 20 | 21 | mapContainer: ContentView; 22 | mapboxView: MapboxView; 23 | mapbox: MapboxApi; 24 | 25 | markers: MapboxMarker[] = []; 26 | 27 | ngOnInit() { 28 | console.log('----- MapboxDemo2Component initialized'); 29 | Trace.addCategories(MapboxTraceCategory); 30 | Trace.enable(); 31 | } 32 | 33 | loadedMap(args: EventData) { 34 | this.mapContainer = args.object as ContentView; 35 | const settings = { 36 | container: this.mapContainer, 37 | accessToken: MAPBOX_ACCESS_TOKEN, 38 | style: MapStyle.TRAFFIC_DAY, 39 | center: { 40 | lat: 50.681466, 41 | lng: 17.8687037 42 | }, 43 | zoomLevel: 12, // 0 (most of the world) to 20, default 0 44 | showUserLocation: false, // default false 45 | hideAttribution: true, // default false 46 | hideLogo: true, // default false 47 | hideCompass: false, // default false 48 | disableRotation: false, // default false 49 | disableScroll: false, // default false 50 | disableZoom: false, // default false 51 | disableTilt: false // default false 52 | }; 53 | 54 | const mapView = new MapboxView(); 55 | mapView.setConfig(settings); 56 | this.mapContainer.content = mapView; 57 | this.mapReady(mapView); 58 | } 59 | 60 | mapReady(mapView: MapboxView): void { 61 | mapView.on('mapReady', (args: any) => { 62 | this.mapboxView = args.map; 63 | this.mapbox = this.mapboxView.getMapboxApi(); 64 | this.cd.detectChanges(); 65 | console.log('mapboxView map is ready:', this.mapboxView); 66 | }); 67 | } 68 | 69 | goBack(): void { 70 | this.router.back(); 71 | } 72 | 73 | ngOnDestroy(): void { 74 | if (this.mapbox) { 75 | this.mapbox.destroy(); 76 | } 77 | } 78 | 79 | goToMapbox(route: string) { 80 | this.router.navigate([route]).then((r) => { 81 | console.log(`Navigation to ${route} successful: `, r); 82 | }); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/ui-mapbox/markers/Marker.android.ts: -------------------------------------------------------------------------------- 1 | import { Application, Color, Label, StackLayout, Trace, Utils } from '@nativescript/core'; 2 | import { CLog, CLogTypes } from '../common'; 3 | 4 | /** 5 | * Hybrid Marker — uses native Mapbox annotation APIs, but NativeScript view for info window. 6 | */ 7 | export class AndroidMarker { 8 | position: com.mapbox.geojson.Point; 9 | icon: android.graphics.Bitmap; 10 | title?: string; 11 | snippet?: string; 12 | id?: string | number; 13 | 14 | pointAnnotation: com.mapbox.maps.plugin.annotation.generated.PointAnnotation; 15 | viewAnnotation: android.view.View; 16 | view: StackLayout; 17 | anchor: com.mapbox.maps.ViewAnnotationAnchorConfig; 18 | layerId: string; 19 | 20 | constructor(opts: { id: string | number; position: com.mapbox.geojson.Point; icon: android.graphics.Bitmap; title?: string; snippet?: string }) { 21 | 22 | this.position = opts.position; 23 | this.id = opts.id; 24 | this.icon = opts.icon; 25 | this.title = opts.title; 26 | this.snippet = opts.snippet; 27 | } 28 | 29 | /** 30 | * Create the native PointAnnotation 31 | */ 32 | prepareAnnotationMarker(pointAnnotationManager: com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager, layerId: string) { 33 | const IconAnchor = com.mapbox.maps.extension.style.layers.properties.generated.IconAnchor; 34 | const PointAnnotationOptions = com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions; 35 | 36 | this.pointAnnotation = pointAnnotationManager.create( 37 | new PointAnnotationOptions().withPoint(this.position).withIconAnchor(IconAnchor.valueOf('BOTTOM')).withIconImage(this.icon) 38 | ) as com.mapbox.maps.plugin.annotation.generated.PointAnnotation; 39 | this.layerId = layerId; 40 | if (Trace.isEnabled()) { 41 | CLog(CLogTypes.log, 'MarkerManager prepareAnnotationMarker: ' + layerId, this.id, this.pointAnnotation); 42 | } 43 | } 44 | 45 | update(pointAnnotationManager: com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager) { 46 | if (!this.pointAnnotation) { 47 | return; 48 | } 49 | // const PointAnnotationOptions = com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions; 50 | // const IconAnchor = com.mapbox.maps.extension.style.layers.properties.generated.IconAnchor; 51 | this.pointAnnotation.setGeometry(this.position); 52 | // this.pointAnnotation.setIconAnchor(IconAnchor.BOTTOM); 53 | this.pointAnnotation.setIconImageBitmap(this.icon); 54 | // 2. Update the annotation via the manager 55 | pointAnnotationManager.update(this.pointAnnotation); 56 | if (this.view) { 57 | const title = this.view.getViewById('title'); 58 | title.text = this?.title || ''; 59 | const subtitle = this.view.getViewById('subtitle'); 60 | subtitle.text = this?.snippet; 61 | subtitle.visibility = this?.snippet ? 'visible' : 'collapse'; 62 | } 63 | } 64 | 65 | destroy() { 66 | this.view = null; 67 | this.viewAnnotation = null; 68 | this.icon = null; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/ui-mapbox/typings/index.android.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace com { 2 | export namespace nativescript { 3 | export namespace mapbox { 4 | export namespace Telemetry { 5 | function setUserTelemetryRequestState(mapView: com.mapbox.maps.MapView, param0: boolean); 6 | 7 | } 8 | export namespace Camera { 9 | function flyTo(mapView: com.mapbox.maps.MapView, param0: com.mapbox.maps.CameraOptions, param1: com.mapbox.maps.plugin.animation.MapAnimationOptions, param2: globalAndroid.animation.Animator.AnimatorListener): com.mapbox.common.Cancelable; 10 | function setCamera(mapView: com.mapbox.maps.MapView, param0: com.mapbox.maps.CameraOptions); 11 | } 12 | export namespace ViewAnnotationManager { 13 | function getViewAnnotationManager(map: com.mapbox.maps.MapView): com.mapbox.maps.viewannotation.ViewAnnotationManager; 14 | function addViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View, options: com.mapbox.maps.ViewAnnotationOptions); 15 | function updateViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View, options: com.mapbox.maps.ViewAnnotationOptions); 16 | function removeViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View); 17 | function getViewAnnotationOptions(map: com.mapbox.maps.MapView, view: android.view.View): com.mapbox.maps.ViewAnnotationOptions?; 18 | function addOnViewAnnotationUpdatedListener(map: com.mapbox.maps.MapView, listener: com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener); 19 | function removeOnViewAnnotationUpdatedListener(map: com.mapbox.maps.MapView, listener: com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener); 20 | } 21 | export namespace Utils { 22 | export namespace Companion { 23 | function getViewAnnotationManager(map: com.mapbox.maps.MapView): com.mapbox.maps.viewannotation.ViewAnnotationManager; 24 | function addViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View, options: com.mapbox.maps.ViewAnnotationOptions); 25 | function updateViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View, options: com.mapbox.maps.ViewAnnotationOptions); 26 | function removeViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View); 27 | function getViewAnnotationOptions(map: com.mapbox.maps.MapView, view: android.view.View): com.mapbox.maps.ViewAnnotationOptions?; 28 | function addOnViewAnnotationUpdatedListener(map: com.mapbox.maps.MapView, listener: com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener); 29 | function removeOnViewAnnotationUpdatedListener(map: com.mapbox.maps.MapView, listener: com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener); 30 | } 31 | } 32 | } 33 | } 34 | } 35 | 36 | declare namespace com { 37 | export namespace mapbox { 38 | export namespace maps { 39 | export namespace MapInitOptions { 40 | export namespace Companion { 41 | function getDefaultPluginList(): java.util.List; 42 | } 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /demo-snippets/ng/mapbox-demo2/mapbox-demo2.component.ts: -------------------------------------------------------------------------------- 1 | import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, NO_ERRORS_SCHEMA, NgZone, OnDestroy, OnInit, ViewChild, inject } from '@angular/core'; 2 | import { ActionBarComponent, NavigationButtonDirective, RouterExtensions, registerElement } from '@nativescript/angular'; 3 | import { MapStyle, MapboxApi, MapboxMarker, MapboxTraceCategory, MapboxView } from '@nativescript-community/ui-mapbox'; 4 | import { Trace } from '@nativescript/core'; 5 | import { MapboxHeaderComponent } from '../mapbox-header/mapbox-header.component'; 6 | import { MAPBOX_ACCESS_TOKEN } from '../mapbox-token'; 7 | import { MapboxFooterComponent } from '../mapbox-footer/mapbox-footer.component'; 8 | 9 | registerElement('Mapbox', () => require('@nativescript-community/ui-mapbox').MapboxView); 10 | 11 | @Component({ 12 | selector: 'app-mapbox-demo2', 13 | templateUrl: './mapbox-demo2.component.html', 14 | schemas: [NO_ERRORS_SCHEMA], 15 | imports: [ActionBarComponent, NavigationButtonDirective, MapboxHeaderComponent, MapboxFooterComponent] 16 | }) 17 | export class MapboxDemo2Component implements OnInit, AfterViewInit, OnDestroy { 18 | router: RouterExtensions = inject(RouterExtensions); 19 | cd: ChangeDetectorRef = inject(ChangeDetectorRef); 20 | ngZone: NgZone = inject(NgZone); 21 | 22 | @ViewChild('mapContainer', { static: false }) public mapContainerRef: ElementRef; 23 | 24 | mapboxView: MapboxView; 25 | mapbox: MapboxApi; 26 | 27 | markers: MapboxMarker[] = []; 28 | 29 | ngOnInit() { 30 | console.log('----- MapboxDemo2Component initialized'); 31 | Trace.addCategories(MapboxTraceCategory); 32 | Trace.enable(); 33 | } 34 | 35 | ngAfterViewInit() { 36 | console.log(' mapContainerRef: ', this.mapContainerRef.nativeElement); 37 | 38 | const contentView = this.mapContainerRef.nativeElement; 39 | 40 | const settings = { 41 | container: contentView, 42 | accessToken: MAPBOX_ACCESS_TOKEN, 43 | style: MapStyle.TRAFFIC_DAY, 44 | center: { 45 | lat: 50.681466, 46 | lng: 17.8687037 47 | }, 48 | zoomLevel: 12, // 0 (most of the world) to 20, default 0 49 | showUserLocation: false, // default false 50 | hideAttribution: true, // default false 51 | hideLogo: true, // default false 52 | hideCompass: false, // default false 53 | disableRotation: false, // default false 54 | disableScroll: false, // default false 55 | disableZoom: false, // default false 56 | disableTilt: false // default false 57 | }; 58 | 59 | const mapView = new MapboxView(); 60 | mapView.setConfig(settings); 61 | contentView.content = mapView; 62 | this.mapReady(mapView); 63 | } 64 | 65 | mapReady(mapView: MapboxView): void { 66 | mapView.on('mapReady', (args: any) => { 67 | this.mapboxView = args.map; 68 | this.mapbox = this.mapboxView.getMapboxApi(); 69 | this.cd.detectChanges(); 70 | console.log('mapboxView map is ready:', this.mapboxView); 71 | }); 72 | } 73 | 74 | goBack(): void { 75 | this.router.back(); 76 | } 77 | 78 | ngOnDestroy(): void { 79 | if (this.mapbox) { 80 | this.mapbox.destroy(); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: 'release' 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | release_type: 7 | type: choice 8 | default: auto 9 | description: What kind of version upgrade 10 | options: 11 | - auto 12 | - patch 13 | - minor 14 | - major 15 | 16 | jobs: 17 | release: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Checkout repository 21 | uses: actions/checkout@v4 22 | with: 23 | fetch-depth: "0" 24 | submodules: true 25 | 26 | - name: setup node 27 | uses: actions/setup-node@v4 28 | with: 29 | node-version: lts/* 30 | registry-url: 'https://registry.npmjs.org' 31 | 32 | 33 | - uses: oNaiPs/secrets-to-env-action@v1 34 | with: 35 | secrets: ${{ toJSON(secrets) }} 36 | 37 | 38 | - uses: oleksiyrudenko/gha-git-credentials@v2-latest 39 | with: 40 | token: '${{ secrets.GITHUB_TOKEN }}' 41 | name: Martin Guillon 42 | email: dev@akylas.fr 43 | 44 | - name: install jq 45 | run: sudo apt install jq 46 | 47 | - name: Enable CorePack 48 | run: | 49 | corepack enable 50 | yarn config get globalFolder # the yarn command will ensure the correct yarn version is downloaded and installed 51 | 52 | - name: Get yarn cache directory path 53 | id: yarn-cache-dir-path 54 | run: echo "::set-output name=dir::$(yarn config get globalFolder)" 55 | 56 | - name: Remove package.json resolutions 57 | run: echo "`jq 'delpaths([["resolutions"]])' package.json`" > package.json 58 | 59 | - uses: actions/cache@v4 60 | name: Handle node_modules Cache 61 | id: yarn-node_modules # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) 62 | with: 63 | path: node_modules 64 | key: ${{ runner.os }}-yarn-node_modules-${{ hashFiles('**/yarn.lock') }} 65 | restore-keys: | 66 | ${{ runner.os }}-node_modules- 67 | 68 | - uses: actions/cache@v4 69 | if: steps.yarn-node_modules.outputs.cache-hit != 'true' 70 | name: Handle Yarn cache 71 | id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) 72 | with: 73 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 74 | key: ${{ runner.os }}-yarn-cache-${{ hashFiles('**/yarn.lock') }} 75 | restore-keys: | 76 | ${{ runner.os }}-yarn- 77 | 78 | - name: Install deps 79 | if: steps.yarn-node_modules.outputs.cache-hit != 'true' 80 | uses: bahmutov/npm-install@v1 81 | with: 82 | install-command: corepack yarn --silent 83 | env: 84 | YARN_ENABLE_IMMUTABLE_INSTALLS: false 85 | 86 | - name: run setup 87 | run: | 88 | npm run setup 89 | 90 | - name: "NPM Identity" 91 | env: 92 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 93 | run: | 94 | echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc 95 | 96 | - name: publish auto 97 | if: github.event.inputs.release_type == 'auto' 98 | run: | 99 | npm run publish -- --force-publish --no-verify-access --no-private --no-commit-hooks --yes 100 | env: 101 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 102 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 103 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 104 | 105 | - name: publish 106 | if: github.event.inputs.release_type != 'auto' 107 | run: | 108 | npm run publish -- --force-publish --no-verify-access --no-private --no-commit-hooks --yes --bump ${{ github.event.inputs.release_type }} 109 | env: 110 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 111 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 112 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /docs/assets/highlight.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --light-hl-0: #AF00DB; 3 | --dark-hl-0: #CE92A4; 4 | --light-hl-1: #000000; 5 | --dark-hl-1: #D4D4D4; 6 | --light-hl-2: #001080; 7 | --dark-hl-2: #9CDCFE; 8 | --light-hl-3: #A31515; 9 | --dark-hl-3: #CE9178; 10 | --light-hl-4: #795E26; 11 | --dark-hl-4: #DCDCAA; 12 | --light-hl-5: #0000FF; 13 | --dark-hl-5: #569CD6; 14 | --light-hl-6: #800000; 15 | --dark-hl-6: #808080; 16 | --light-hl-7: #CD3131; 17 | --dark-hl-7: #F44747; 18 | --light-hl-8: #E50000; 19 | --dark-hl-8: #9CDCFE; 20 | --light-hl-9: #0000FF; 21 | --dark-hl-9: #CE9178; 22 | --light-hl-10: #008000; 23 | --dark-hl-10: #6A9955; 24 | --light-hl-11: #098658; 25 | --dark-hl-11: #B5CEA8; 26 | --light-hl-12: #267F99; 27 | --dark-hl-12: #4EC9B0; 28 | --light-hl-13: #0070C1; 29 | --dark-hl-13: #4FC1FF; 30 | --light-hl-14: #000000FF; 31 | --dark-hl-14: #D4D4D4; 32 | --light-hl-15: #800000; 33 | --dark-hl-15: #569CD6; 34 | --light-hl-16: #000000; 35 | --dark-hl-16: #C8C8C8; 36 | --light-code-background: #FFFFFF; 37 | --dark-code-background: #1E1E1E; 38 | } 39 | 40 | @media (prefers-color-scheme: light) { :root { 41 | --hl-0: var(--light-hl-0); 42 | --hl-1: var(--light-hl-1); 43 | --hl-2: var(--light-hl-2); 44 | --hl-3: var(--light-hl-3); 45 | --hl-4: var(--light-hl-4); 46 | --hl-5: var(--light-hl-5); 47 | --hl-6: var(--light-hl-6); 48 | --hl-7: var(--light-hl-7); 49 | --hl-8: var(--light-hl-8); 50 | --hl-9: var(--light-hl-9); 51 | --hl-10: var(--light-hl-10); 52 | --hl-11: var(--light-hl-11); 53 | --hl-12: var(--light-hl-12); 54 | --hl-13: var(--light-hl-13); 55 | --hl-14: var(--light-hl-14); 56 | --hl-15: var(--light-hl-15); 57 | --hl-16: var(--light-hl-16); 58 | --code-background: var(--light-code-background); 59 | } } 60 | 61 | @media (prefers-color-scheme: dark) { :root { 62 | --hl-0: var(--dark-hl-0); 63 | --hl-1: var(--dark-hl-1); 64 | --hl-2: var(--dark-hl-2); 65 | --hl-3: var(--dark-hl-3); 66 | --hl-4: var(--dark-hl-4); 67 | --hl-5: var(--dark-hl-5); 68 | --hl-6: var(--dark-hl-6); 69 | --hl-7: var(--dark-hl-7); 70 | --hl-8: var(--dark-hl-8); 71 | --hl-9: var(--dark-hl-9); 72 | --hl-10: var(--dark-hl-10); 73 | --hl-11: var(--dark-hl-11); 74 | --hl-12: var(--dark-hl-12); 75 | --hl-13: var(--dark-hl-13); 76 | --hl-14: var(--dark-hl-14); 77 | --hl-15: var(--dark-hl-15); 78 | --hl-16: var(--dark-hl-16); 79 | --code-background: var(--dark-code-background); 80 | } } 81 | 82 | :root[data-theme='light'] { 83 | --hl-0: var(--light-hl-0); 84 | --hl-1: var(--light-hl-1); 85 | --hl-2: var(--light-hl-2); 86 | --hl-3: var(--light-hl-3); 87 | --hl-4: var(--light-hl-4); 88 | --hl-5: var(--light-hl-5); 89 | --hl-6: var(--light-hl-6); 90 | --hl-7: var(--light-hl-7); 91 | --hl-8: var(--light-hl-8); 92 | --hl-9: var(--light-hl-9); 93 | --hl-10: var(--light-hl-10); 94 | --hl-11: var(--light-hl-11); 95 | --hl-12: var(--light-hl-12); 96 | --hl-13: var(--light-hl-13); 97 | --hl-14: var(--light-hl-14); 98 | --hl-15: var(--light-hl-15); 99 | --hl-16: var(--light-hl-16); 100 | --code-background: var(--light-code-background); 101 | } 102 | 103 | :root[data-theme='dark'] { 104 | --hl-0: var(--dark-hl-0); 105 | --hl-1: var(--dark-hl-1); 106 | --hl-2: var(--dark-hl-2); 107 | --hl-3: var(--dark-hl-3); 108 | --hl-4: var(--dark-hl-4); 109 | --hl-5: var(--dark-hl-5); 110 | --hl-6: var(--dark-hl-6); 111 | --hl-7: var(--dark-hl-7); 112 | --hl-8: var(--dark-hl-8); 113 | --hl-9: var(--dark-hl-9); 114 | --hl-10: var(--dark-hl-10); 115 | --hl-11: var(--dark-hl-11); 116 | --hl-12: var(--dark-hl-12); 117 | --hl-13: var(--dark-hl-13); 118 | --hl-14: var(--dark-hl-14); 119 | --hl-15: var(--dark-hl-15); 120 | --hl-16: var(--dark-hl-16); 121 | --code-background: var(--dark-code-background); 122 | } 123 | 124 | .hl-0 { color: var(--hl-0); } 125 | .hl-1 { color: var(--hl-1); } 126 | .hl-2 { color: var(--hl-2); } 127 | .hl-3 { color: var(--hl-3); } 128 | .hl-4 { color: var(--hl-4); } 129 | .hl-5 { color: var(--hl-5); } 130 | .hl-6 { color: var(--hl-6); } 131 | .hl-7 { color: var(--hl-7); } 132 | .hl-8 { color: var(--hl-8); } 133 | .hl-9 { color: var(--hl-9); } 134 | .hl-10 { color: var(--hl-10); } 135 | .hl-11 { color: var(--hl-11); } 136 | .hl-12 { color: var(--hl-12); } 137 | .hl-13 { color: var(--hl-13); } 138 | .hl-14 { color: var(--hl-14); } 139 | .hl-15 { color: var(--hl-15); } 140 | .hl-16 { color: var(--hl-16); } 141 | pre, code { background: var(--code-background); } 142 | -------------------------------------------------------------------------------- /docs/variables/MapboxTraceCategory.html: -------------------------------------------------------------------------------- 1 | MapboxTraceCategory | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...MapboxTraceCategoryVariable MapboxTraceCategoryConstMapboxTraceCategory: "NativescriptMapbox"SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/delayProperty.html: -------------------------------------------------------------------------------- 1 | delayProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...delayPropertyVariable delayPropertyConstdelayProperty: Property<MapboxViewCommonBase, number>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/hideLogoProperty.html: -------------------------------------------------------------------------------- 1 | hideLogoProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...hideLogoPropertyVariable hideLogoPropertyConsthideLogoProperty: Property<MapboxViewCommonBase, boolean>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/latitudeProperty.html: -------------------------------------------------------------------------------- 1 | latitudeProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...latitudePropertyVariable latitudePropertyConstlatitudeProperty: Property<MapboxViewCommonBase, number>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/mapStyleProperty.html: -------------------------------------------------------------------------------- 1 | mapStyleProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...mapStylePropertyVariable mapStylePropertyConstmapStyleProperty: Property<MapboxViewCommonBase, string>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/longitudeProperty.html: -------------------------------------------------------------------------------- 1 | longitudeProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...longitudePropertyVariable longitudePropertyConstlongitudeProperty: Property<MapboxViewCommonBase, number>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/telemetryProperty.html: -------------------------------------------------------------------------------- 1 | telemetryProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...telemetryPropertyVariable telemetryPropertyConsttelemetryProperty: Property<MapboxViewCommonBase, boolean>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/zoomLevelProperty.html: -------------------------------------------------------------------------------- 1 | zoomLevelProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...zoomLevelPropertyVariable zoomLevelPropertyConstzoomLevelProperty: Property<MapboxViewCommonBase, number>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/accessTokenProperty.html: -------------------------------------------------------------------------------- 1 | accessTokenProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...accessTokenPropertyVariable accessTokenPropertyConstaccessTokenProperty: Property<MapboxViewCommonBase, string>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/disableTiltProperty.html: -------------------------------------------------------------------------------- 1 | disableTiltProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...disableTiltPropertyVariable disableTiltPropertyConstdisableTiltProperty: Property<MapboxViewCommonBase, boolean>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/disableZoomProperty.html: -------------------------------------------------------------------------------- 1 | disableZoomProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...disableZoomPropertyVariable disableZoomPropertyConstdisableZoomProperty: Property<MapboxViewCommonBase, boolean>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/hideCompassProperty.html: -------------------------------------------------------------------------------- 1 | hideCompassProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...hideCompassPropertyVariable hideCompassPropertyConsthideCompassProperty: Property<MapboxViewCommonBase, boolean>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/disableScrollProperty.html: -------------------------------------------------------------------------------- 1 | disableScrollProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...disableScrollPropertyVariable disableScrollPropertyConstdisableScrollProperty: Property<MapboxViewCommonBase, boolean>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/types/AddSourceOptions.html: -------------------------------------------------------------------------------- 1 | AddSourceOptions | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...AddSourceOptionsType Alias AddSourceOptionsAddSourceOptions: VectorSource | GeoJSONSource | RasterSourceSettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/disableRotationProperty.html: -------------------------------------------------------------------------------- 1 | disableRotationProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...disableRotationPropertyVariable disableRotationPropertyConstdisableRotationProperty: Property<MapboxViewCommonBase, boolean>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/hideAttributionProperty.html: -------------------------------------------------------------------------------- 1 | hideAttributionProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...hideAttributionPropertyVariable hideAttributionPropertyConsthideAttributionProperty: Property<MapboxViewCommonBase, boolean>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/showUserLocationProperty.html: -------------------------------------------------------------------------------- 1 | showUserLocationProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...showUserLocationPropertyVariable showUserLocationPropertyConstshowUserLocationProperty: Property<MapboxViewCommonBase, boolean>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/types/UpdateSourceOptions.html: -------------------------------------------------------------------------------- 1 | UpdateSourceOptions | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...UpdateSourceOptionsType Alias UpdateSourceOptionsUpdateSourceOptions: VectorSource | GeoJSONSource | RasterSourceSettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/logoPositionProperty.html: -------------------------------------------------------------------------------- 1 | logoPositionProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...logoPositionPropertyVariable logoPositionPropertyConstlogoPositionProperty: Property<MapboxViewCommonBase, ControlPosition>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/locationComponentOptionsProperty.html: -------------------------------------------------------------------------------- 1 | locationComponentOptionsProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...locationComponentOptionsPropertyVariable locationComponentOptionsPropertyConstlocationComponentOptionsProperty: Property<MapboxViewCommonBase, object>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/types/UserTrackingMode.html: -------------------------------------------------------------------------------- 1 | UserTrackingMode | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...UserTrackingModeType Alias UserTrackingModeUserTrackingMode: | "NONE" | "FOLLOW" | "FOLLOW_WITH_HEADING" | "FOLLOW_WITH_COURSE"SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/compassPositionProperty.html: -------------------------------------------------------------------------------- 1 | compassPositionProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...compassPositionPropertyVariable compassPositionPropertyConstcompassPositionProperty: Property<MapboxViewCommonBase, ControlPosition>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/attributionPositionProperty.html: -------------------------------------------------------------------------------- 1 | attributionPositionProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...attributionPositionPropertyVariable attributionPositionPropertyConstattributionPositionProperty: Property<MapboxViewCommonBase, ControlPosition>SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/types/SupportedLayerType.html: -------------------------------------------------------------------------------- 1 | SupportedLayerType | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...SupportedLayerTypeType Alias SupportedLayerTypeSupportedLayerType: LayerType & ( "line" | "circle" | "fill" | "symbol" | "raster")SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /packages/ui-mapbox/platforms/android/java/com/nativescript/mapbox/Utils.kt: -------------------------------------------------------------------------------- 1 | package com.nativescript.mapbox 2 | 3 | import com.mapbox.maps.MapView 4 | import com.mapbox.maps.plugin.animation.CameraAnimationsPlugin 5 | import com.mapbox.maps.plugin.animation.camera 6 | import com.mapbox.maps.plugin.annotation.annotations 7 | import com.mapbox.maps.plugin.annotation.generated.createPointAnnotationManager 8 | import android.util.Log 9 | 10 | class Telemetry { 11 | companion object { 12 | @JvmStatic 13 | fun setUserTelemetryRequestState(mapView: MapView, value: Boolean) { 14 | val fakeManager = mapView.annotations.createPointAnnotationManager() 15 | fakeManager.delegateProvider.mapAttributionDelegate.telemetry().setUserTelemetryRequestState(value) 16 | } 17 | } 18 | } 19 | class Camera { 20 | companion object { 21 | fun getCamera(mapView: MapView): CameraAnimationsPlugin { 22 | return mapView.camera 23 | } 24 | /** 25 | * Returns the CameraAnimationsPlugin associated with the given MapView. 26 | * 27 | * Once you have this object in NativeScript, you can directly call: 28 | * camera.flyTo(...) 29 | * camera.easeTo(...) 30 | * camera.cancelTransitions() 31 | */ 32 | @JvmStatic 33 | fun flyTo(mapView: MapView, cameraOptions: com.mapbox.maps.CameraOptions, animationOptions: com.mapbox.maps.plugin.animation.MapAnimationOptions, listener: android.animation.Animator.AnimatorListener?): com.mapbox.common.Cancelable { 34 | return mapView.camera.flyTo(cameraOptions, animationOptions, listener) 35 | } 36 | @JvmStatic 37 | fun setCamera(mapView: MapView, cameraOptions: com.mapbox.maps.CameraOptions) { 38 | mapView.mapboxMap.setCamera(cameraOptions) 39 | } 40 | } 41 | } 42 | 43 | class ViewAnnotationManager { 44 | companion object { 45 | @JvmStatic 46 | fun addViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View, options: com.mapbox.maps.ViewAnnotationOptions) { 47 | map.viewAnnotationManager.addViewAnnotation(view, options) 48 | } 49 | @JvmStatic 50 | fun removeViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View) { 51 | map.viewAnnotationManager.removeViewAnnotation(view) 52 | } 53 | @JvmStatic 54 | fun updateViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View, options: com.mapbox.maps.ViewAnnotationOptions) { 55 | map.viewAnnotationManager.updateViewAnnotation(view, options) 56 | } 57 | @JvmStatic 58 | fun getViewAnnotationOptions(map: com.mapbox.maps.MapView, view: android.view.View): com.mapbox.maps.ViewAnnotationOptions? { 59 | return map.viewAnnotationManager.getViewAnnotationOptions(view) 60 | } 61 | @JvmStatic 62 | fun addOnViewAnnotationUpdatedListener(map: com.mapbox.maps.MapView, listener: com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener) { 63 | map.viewAnnotationManager.addOnViewAnnotationUpdatedListener(listener) 64 | } 65 | @JvmStatic 66 | fun removeOnViewAnnotationUpdatedListener(map: com.mapbox.maps.MapView, listener: com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener) { 67 | map.viewAnnotationManager.removeOnViewAnnotationUpdatedListener(listener) 68 | } 69 | } 70 | } 71 | 72 | class Utils { 73 | companion object { 74 | fun getViewAnnotationManager(map: MapView): com.mapbox.maps.viewannotation.ViewAnnotationManager { 75 | return map.viewAnnotationManager 76 | } 77 | // fun getCamera(map: com.mapbox.maps.MapView): com.mapbox.maps.plugin.animation.CameraAnimationsPlugin { 78 | // return map.getPlugin("MAPBOX_CAMERA_PLUGIN_ID") 79 | // } 80 | // fun getTelemetry(map: com.mapbox.maps.MapView): com.mapbox.maps.module.MapTelemetry { 81 | // return map.telemetry 82 | // } 83 | fun addViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View, options: com.mapbox.maps.ViewAnnotationOptions) { 84 | map.viewAnnotationManager.addViewAnnotation(view, options) 85 | } 86 | fun removeViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View) { 87 | map.viewAnnotationManager.removeViewAnnotation(view) 88 | } 89 | fun updateViewAnnotation(map: com.mapbox.maps.MapView, view: android.view.View, options: com.mapbox.maps.ViewAnnotationOptions) { 90 | map.viewAnnotationManager.updateViewAnnotation(view, options) 91 | } 92 | fun getViewAnnotationOptions(map: com.mapbox.maps.MapView, view: android.view.View): com.mapbox.maps.ViewAnnotationOptions? { 93 | return map.viewAnnotationManager.getViewAnnotationOptions(view) 94 | } 95 | fun addOnViewAnnotationUpdatedListener(map: com.mapbox.maps.MapView, listener: com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener) { 96 | map.viewAnnotationManager.addOnViewAnnotationUpdatedListener(listener) 97 | } 98 | fun removeOnViewAnnotationUpdatedListener(map: com.mapbox.maps.MapView, listener: com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener) { 99 | map.viewAnnotationManager.removeOnViewAnnotationUpdatedListener(listener) 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /packages/ui-mapbox/platforms/ios/src/NativeLayerFactory.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | import MapboxMaps 4 | 5 | @objcMembers 6 | public class NativeLayerFactory: NSObject { 7 | 8 | // Create a layer from JSON. Returns true on success. 9 | @objc public static func createLayer(_ mapboxView: MapView, _ layerId: String, _ jsonString: String, _ belowLayerId: String?) -> Bool { 10 | guard let mapboxMap = mapboxView.mapboxMap, let data = jsonString.data(using: .utf8) else { return false } 11 | do { 12 | // Parse to a JSON dictionary 13 | guard let jsonObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else { 14 | throw NSError(domain: "LayerError", code: 0, userInfo: [NSLocalizedDescriptionKey: "Invalid JSON"]) 15 | } 16 | 17 | guard let typeString = jsonObject["type"] as? String, 18 | let type = LayerType(rawValue: typeString).layerType else { 19 | throw TypeConversionError.invalidObject 20 | } 21 | 22 | let layer = try type.init(jsonObject: jsonObject) 23 | if (belowLayerId != nil) { 24 | try mapboxMap.addLayer(layer, layerPosition: .below(belowLayerId!)) 25 | } else { 26 | try mapboxMap.addLayer(layer) 27 | } 28 | return true 29 | } catch { 30 | return false 31 | } 32 | } 33 | 34 | /// Apply a set of properties to an existing layer by calling setLayerProperty for each key. 35 | /// This avoids removing/adding the layer and uses the style API to set properties in-place. 36 | @objc public static func applyLayerProperties(_ mapboxView: MapView, _ layerId: String, _ properties: NSDictionary) -> Bool { 37 | guard mapboxView.mapboxMap != nil else { return false } 38 | // Iterate keys and call style.setLayerProperty(for:property:value:) 39 | var succeeded = true 40 | for (k, v) in properties { 41 | guard let key = k as? String else { continue } 42 | let ok = setLayerProperty(mapboxView, layerId, key, v as Any) 43 | if !ok { succeeded = false } 44 | } 45 | return succeeded 46 | } 47 | 48 | /// Set a single layer property in-place using the style API. 49 | /// Example property paths: "paint.fill-color", "layout.visibility", etc. 50 | @objc public static func setLayerProperty(_ mapboxView: MapView, _ layerId: String, _ name: String, _ value: Any) -> Bool { 51 | guard let mapboxMap = mapboxView.mapboxMap else { return false } 52 | do { 53 | // MapboxMaps (11.x) exposes setLayerProperty(for:property:value:) 54 | // Use the API directly and propagate errors. 55 | try mapboxMap.setLayerProperty(for: layerId, property: name, value: value) 56 | return true 57 | } catch { 58 | // Some SDK variants may expect different types (e.g., NSNumber vs String). Try best-effort conversions for common types. 59 | // If value is NSString representing a color (e.g. "#ff0000"), it's usually accepted by the SDK. 60 | return false 61 | } 62 | } 63 | 64 | // Set layer visibility 65 | @objc public static func setLayerVisibility(_ mapboxView: MapView, _ layerId: String, _ visible: Bool) -> Bool { 66 | return setLayerProperty(mapboxView, layerId, "layout.visibility", visible ? "visible" : "none") 67 | } 68 | // Set layer visibility 69 | @objc public static func getLayerProperty(_ mapboxView: MapView, _ layerId: String, _ name: String) -> Any? { 70 | guard let mapboxMap = mapboxView.mapboxMap else { return nil } 71 | return mapboxMap.layerProperty(for: layerId, property: name) 72 | } 73 | // ------------------------------- 74 | // Native getters for layer ids/info 75 | // ------------------------------- 76 | 77 | /// Return the layer id if the layer exists, otherwise nil. 78 | /// JS can call this to validate layer presence. 79 | @objc public static func getLayer(_ mapboxView: MapView, _ layerId: String) -> NSString? { 80 | guard let mapboxMap = mapboxView.mapboxMap else { return nil } 81 | do { 82 | // Try to fetch the layer; if it exists return the id string (opaque success marker) 83 | _ = try mapboxMap.layer(withId: layerId) 84 | return layerId as NSString 85 | } catch { 86 | return nil 87 | } 88 | } 89 | 90 | /// Return an array (JSON string) of layer ids in the current style. 91 | @objc public static func getLayers(_ mapboxView: MapView) -> NSString? { 92 | guard let mapboxMap = mapboxView.mapboxMap else { return nil } 93 | var ids: [String] = [] 94 | for info in mapboxMap.allLayerIdentifiers { 95 | ids.append(info.id) 96 | } 97 | if let data = try? JSONSerialization.data(withJSONObject: ids, options: []), 98 | let s = String(data: data, encoding: .utf8) { 99 | return s as NSString 100 | } 101 | return nil 102 | } 103 | 104 | /// Return the layer 'type' string for the given layer id (e.g. "fill", "line", "symbol"), or nil. 105 | @objc public static func getLayerType(_ mapboxView: MapView, _ layerId: String) -> NSString? { 106 | return getLayerProperty(mapboxView, layerId, "type") as? NSString 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /docs/types/UserLocationCameraMode.html: -------------------------------------------------------------------------------- 1 | UserLocationCameraMode | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...UserLocationCameraModeType Alias UserLocationCameraModeUserLocationCameraMode: | "NONE" | "NONE_COMPASS" | "NONE_GPS" | "TRACKING" | "TRACKING_COMPASS" | "TRACKING_GPS" | "TRACKING_GPS_NORTH"SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 2 | -------------------------------------------------------------------------------- /docs/variables/mapReadyProperty.html: -------------------------------------------------------------------------------- 1 | mapReadyProperty | A Nativescript plugin for Mapbox Native Maps.A Nativescript plugin for Mapbox Native Maps.Nativescript DocPreparing search index...mapReadyPropertyVariable mapReadyPropertyConstmapReadyProperty: Property<MapboxViewCommonBase, string>Properties definitions for the Mapbox XML tag. 2 | Linkhttps://docs.nativescript.org/plugins/ui-plugin-custom 3 | SettingsMember VisibilityProtectedInheritedThemeOSLightDarkNativescript DocA Nativescript plugin for Mapbox Native Maps.Loading... 4 | --------------------------------------------------------------------------------
Const
Properties definitions for the Mapbox XML tag.
https://docs.nativescript.org/plugins/ui-plugin-custom