@nativescript-community/ui-mapbox 6.2.31 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/common.d.ts +56 -26
- package/common.js +44 -28
- package/expression/expression-parser.android.d.ts +2 -2
- package/expression/expression-parser.android.js +4 -3
- package/expression/expression-parser.ios.d.ts +2 -2
- package/expression/expression-parser.ios.js +28 -13
- package/index.android.d.ts +59 -66
- package/index.android.js +1388 -1244
- package/index.d.ts +36 -5
- package/index.ios.d.ts +72 -243
- package/index.ios.js +1161 -1999
- package/layers/layer-factory.android.d.ts +7 -5
- package/layers/layer-factory.android.js +71 -41
- package/layers/layer-factory.d.ts +2 -1
- package/layers/layer-factory.ios.d.ts +8 -8
- package/layers/layer-factory.ios.js +46 -100
- package/layers/parser/property-parser.android.d.ts +3 -1
- package/layers/parser/property-parser.android.js +25 -24
- package/layers/parser/property-parser.d.ts +1 -1
- package/layers/parser/property-parser.ios.d.ts +0 -2
- package/layers/parser/property-parser.ios.js +0 -149
- package/markers/Marker.android.d.ts +28 -0
- package/markers/Marker.android.js +54 -0
- package/markers/Marker.common.d.ts +2 -0
- package/markers/Marker.common.js +31 -0
- package/markers/MarkerManager.android.d.ts +35 -0
- package/markers/MarkerManager.android.js +220 -0
- package/package.json +7 -6
- package/platforms/android/include.gradle +31 -27
- package/platforms/android/ui_mapbox.aar +0 -0
- package/platforms/ios/Podfile +3 -1
- package/platforms/ios/Resources/default_pin.png +0 -0
- package/platforms/ios/src/MapboxBridge.swift +1479 -0
- package/platforms/ios/src/NativeExpressionParser.swift +33 -0
- package/platforms/ios/src/NativeLayerFactory.swift +108 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/typings/Mapbox.ios.d.ts +2 -3242
- package/typings/geojson.android.d.ts +689 -0
- package/typings/index.android.d.ts +46 -0
- package/typings/mapbox.android.d.ts +39968 -12560
- package/typings/mapbox.bridge.ios.d.ts +129 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { StackLayout } from '@nativescript/core';
|
|
2
|
+
/**
|
|
3
|
+
* Hybrid Marker — uses native Mapbox annotation APIs, but NativeScript view for info window.
|
|
4
|
+
*/
|
|
5
|
+
export declare class AndroidMarker {
|
|
6
|
+
position: com.mapbox.geojson.Point;
|
|
7
|
+
icon: android.graphics.Bitmap;
|
|
8
|
+
title?: string;
|
|
9
|
+
snippet?: string;
|
|
10
|
+
pointAnnotation: com.mapbox.maps.plugin.annotation.generated.PointAnnotation;
|
|
11
|
+
viewAnnotation: android.view.View;
|
|
12
|
+
view: StackLayout;
|
|
13
|
+
anchor: com.mapbox.maps.ViewAnnotationAnchorConfig;
|
|
14
|
+
layerId: string;
|
|
15
|
+
prepared: boolean;
|
|
16
|
+
constructor(opts: {
|
|
17
|
+
position: com.mapbox.geojson.Point;
|
|
18
|
+
icon: android.graphics.Bitmap;
|
|
19
|
+
title?: string;
|
|
20
|
+
snippet?: string;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Create the native PointAnnotation
|
|
24
|
+
*/
|
|
25
|
+
prepareAnnotationMarker(pointAnnotationManager: com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager, layerId: string): void;
|
|
26
|
+
update(pointAnnotationManager: com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager): void;
|
|
27
|
+
destroy(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Trace } from '@nativescript/core';
|
|
2
|
+
import { CLog, CLogTypes } from '../common';
|
|
3
|
+
/**
|
|
4
|
+
* Hybrid Marker — uses native Mapbox annotation APIs, but NativeScript view for info window.
|
|
5
|
+
*/
|
|
6
|
+
export class AndroidMarker {
|
|
7
|
+
constructor(opts) {
|
|
8
|
+
this.prepared = false;
|
|
9
|
+
if (!opts.title && !opts.snippet) {
|
|
10
|
+
throw new Error('Marker should have either title or snippet!');
|
|
11
|
+
}
|
|
12
|
+
this.position = opts.position;
|
|
13
|
+
this.icon = opts.icon;
|
|
14
|
+
this.title = opts.title;
|
|
15
|
+
this.snippet = opts.snippet;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create the native PointAnnotation
|
|
19
|
+
*/
|
|
20
|
+
prepareAnnotationMarker(pointAnnotationManager, layerId) {
|
|
21
|
+
const IconAnchor = com.mapbox.maps.extension.style.layers.properties.generated.IconAnchor;
|
|
22
|
+
const PointAnnotationOptions = com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions;
|
|
23
|
+
this.pointAnnotation = pointAnnotationManager.create(new PointAnnotationOptions().withPoint(this.position).withIconAnchor(IconAnchor.valueOf('BOTTOM')).withIconImage(this.icon));
|
|
24
|
+
this.layerId = layerId;
|
|
25
|
+
if (Trace.isEnabled()) {
|
|
26
|
+
CLog(CLogTypes.log, 'MarkerManager prepareAnnotationMarker: ' + layerId);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
update(pointAnnotationManager) {
|
|
30
|
+
if (!this.pointAnnotation) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// const PointAnnotationOptions = com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions;
|
|
34
|
+
// const IconAnchor = com.mapbox.maps.extension.style.layers.properties.generated.IconAnchor;
|
|
35
|
+
this.pointAnnotation.setGeometry(this.position);
|
|
36
|
+
// this.pointAnnotation.setIconAnchor(IconAnchor.BOTTOM);
|
|
37
|
+
this.pointAnnotation.setIconImageBitmap(this.icon);
|
|
38
|
+
// 2. Update the annotation via the manager
|
|
39
|
+
pointAnnotationManager.update(this.pointAnnotation);
|
|
40
|
+
if (this.view) {
|
|
41
|
+
const title = this.view.getViewById('title');
|
|
42
|
+
title.text = this?.title || '';
|
|
43
|
+
const subtitle = this.view.getViewById('subtitle');
|
|
44
|
+
subtitle.text = this?.snippet;
|
|
45
|
+
subtitle.visibility = this?.snippet ? 'visible' : 'collapse';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
destroy() {
|
|
49
|
+
this.view = null;
|
|
50
|
+
this.viewAnnotation = null;
|
|
51
|
+
this.icon = null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=Marker.android.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Color, Label, StackLayout } from '@nativescript/core';
|
|
2
|
+
const MARKER_PADDING_PX = 10;
|
|
3
|
+
export function createInfoWindowView(title, snippet) {
|
|
4
|
+
const view = new StackLayout();
|
|
5
|
+
view.className = 'mapbox-info-window';
|
|
6
|
+
view.padding = MARKER_PADDING_PX;
|
|
7
|
+
view.backgroundColor = 'white';
|
|
8
|
+
view.width = 'auto'; // WRAP_CONTENT
|
|
9
|
+
view.height = 'auto'; // WRAP_CONTENT
|
|
10
|
+
view.borderRadius = 12;
|
|
11
|
+
view['shadowColor'] = '#000';
|
|
12
|
+
view['shadowOpacity'] = 0.25;
|
|
13
|
+
view['shadowRadius'] = 8;
|
|
14
|
+
const titleLabel = new Label();
|
|
15
|
+
titleLabel.id = 'title';
|
|
16
|
+
titleLabel.text = title;
|
|
17
|
+
titleLabel.className = 'mapbox-info-window-title';
|
|
18
|
+
titleLabel.fontSize = 16;
|
|
19
|
+
titleLabel.fontWeight = 'bold';
|
|
20
|
+
view.addChild(titleLabel);
|
|
21
|
+
const subtitle = new Label();
|
|
22
|
+
subtitle.id = 'subtitle';
|
|
23
|
+
subtitle.text = snippet;
|
|
24
|
+
subtitle.className = 'mapbox-info-window-snippet';
|
|
25
|
+
subtitle.fontSize = 14;
|
|
26
|
+
// subtitle.visibility = snippet ? 'visible' : 'collapse';
|
|
27
|
+
subtitle.color = new Color('#555');
|
|
28
|
+
view.addChild(subtitle);
|
|
29
|
+
return view;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=Marker.common.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AndroidMarker } from './Marker.android';
|
|
2
|
+
/**
|
|
3
|
+
* MarkerManager (Native Android Mapbox SDK version)
|
|
4
|
+
*/
|
|
5
|
+
export declare class MarkerManager {
|
|
6
|
+
private static readonly MARKER_PADDING_PX;
|
|
7
|
+
private mapView;
|
|
8
|
+
private map;
|
|
9
|
+
private pointAnnotationManager;
|
|
10
|
+
private markerList;
|
|
11
|
+
private static readonly LAYER_ID;
|
|
12
|
+
private static readonly ADDITIONAL_EDGE_PADDING_PX;
|
|
13
|
+
private selectedMarker;
|
|
14
|
+
private onInfoWindowTapped;
|
|
15
|
+
private _reusableCalloutView;
|
|
16
|
+
private onMapClickListener;
|
|
17
|
+
private onPointClickListener;
|
|
18
|
+
onViewAnnotationUpdatedListener: com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener;
|
|
19
|
+
constructor(map: com.mapbox.maps.MapboxMap, mapView: com.mapbox.maps.MapView, onMarkerClick: any, onInfoWindowClick: any);
|
|
20
|
+
deselectAll(): void;
|
|
21
|
+
adjustViewAnnotationXOffset(marker: AndroidMarker): void;
|
|
22
|
+
updateMarker(marker: AndroidMarker): void;
|
|
23
|
+
addMarker(marker: AndroidMarker): AndroidMarker;
|
|
24
|
+
/**
|
|
25
|
+
* Build a NativeScript view to use as info window.
|
|
26
|
+
* Then attach it to Mapbox via ViewAnnotationManager.
|
|
27
|
+
*/
|
|
28
|
+
prepareViewAnnotation(marker: AndroidMarker, onInfoWindowClick: any): void;
|
|
29
|
+
removeMarker(marker: AndroidMarker): void;
|
|
30
|
+
selectMarker(marker: AndroidMarker, deselectIfSelected?: boolean, update?: boolean): void;
|
|
31
|
+
deselectMarker(marker: AndroidMarker): void;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
updateOffsetX(marker: AndroidMarker, leftTop: any, width: number): void;
|
|
34
|
+
isSelected(marker: AndroidMarker): boolean;
|
|
35
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { Application, Trace, Utils } from '@nativescript/core';
|
|
2
|
+
import { CLog, CLogTypes } from '../common';
|
|
3
|
+
import { createInfoWindowView } from './Marker.common';
|
|
4
|
+
/**
|
|
5
|
+
* MarkerManager (Native Android Mapbox SDK version)
|
|
6
|
+
*/
|
|
7
|
+
export class MarkerManager {
|
|
8
|
+
constructor(map, mapView, onMarkerClick, onInfoWindowClick) {
|
|
9
|
+
this.markerList = new Set();
|
|
10
|
+
this.map = map;
|
|
11
|
+
this.mapView = mapView;
|
|
12
|
+
this.onInfoWindowTapped = onInfoWindowClick;
|
|
13
|
+
const AnnotationConfig = com.mapbox.maps.plugin.annotation.AnnotationConfig;
|
|
14
|
+
const layerConfig = new AnnotationConfig(MarkerManager.LAYER_ID);
|
|
15
|
+
const annotationPlugin = mapView.getPlugin('MAPBOX_ANNOTATION_PLUGIN_ID');
|
|
16
|
+
this.pointAnnotationManager = annotationPlugin.createAnnotationManager(com.mapbox.maps.plugin.annotation.AnnotationType.PointAnnotation, layerConfig);
|
|
17
|
+
// add click listeners
|
|
18
|
+
this.onPointClickListener = new com.mapbox.maps.plugin.annotation.generated.OnPointAnnotationClickListener({
|
|
19
|
+
onAnnotationClick: (annotation) => {
|
|
20
|
+
for (const marker of this.markerList) {
|
|
21
|
+
if (marker.pointAnnotation === annotation) {
|
|
22
|
+
if (onMarkerClick(marker)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
this.selectMarker(marker, true);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
this.pointAnnotationManager.addClickListener(this.onPointClickListener);
|
|
32
|
+
// Map click listener to deselect all markers
|
|
33
|
+
this.onMapClickListener = new com.mapbox.maps.plugin.gestures.OnMapClickListener({
|
|
34
|
+
onMapClick: (point) => {
|
|
35
|
+
if (this.selectedMarker) {
|
|
36
|
+
this.deselectMarker(this.selectedMarker);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
com.mapbox.maps.plugin.gestures.GesturesUtils.addOnMapClickListener(map, this.onMapClickListener);
|
|
43
|
+
}
|
|
44
|
+
deselectAll() {
|
|
45
|
+
this.markerList.forEach((marker) => this.deselectMarker(marker));
|
|
46
|
+
}
|
|
47
|
+
adjustViewAnnotationXOffset(marker) {
|
|
48
|
+
const listener = new com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener({
|
|
49
|
+
onViewAnnotationPositionUpdated: (view, leftTopCoordinate, width) => {
|
|
50
|
+
if (view === marker.viewAnnotation) {
|
|
51
|
+
this.updateOffsetX(marker, leftTopCoordinate, width);
|
|
52
|
+
}
|
|
53
|
+
com.nativescript.mapbox.ViewAnnotationManager.removeOnViewAnnotationUpdatedListener(this.mapView, listener);
|
|
54
|
+
},
|
|
55
|
+
onViewAnnotationVisibilityUpdated(view, visible) { },
|
|
56
|
+
onViewAnnotationAnchorCoordinateUpdated(param0, param1) { },
|
|
57
|
+
onViewAnnotationAnchorUpdated(param0, param1) { }
|
|
58
|
+
});
|
|
59
|
+
com.nativescript.mapbox.ViewAnnotationManager.addOnViewAnnotationUpdatedListener(this.mapView, listener);
|
|
60
|
+
}
|
|
61
|
+
updateMarker(marker) {
|
|
62
|
+
// this.adjustViewAnnotationXOffset(marker);
|
|
63
|
+
marker.update(this.pointAnnotationManager);
|
|
64
|
+
com.nativescript.mapbox.ViewAnnotationManager.updateViewAnnotation(this.mapView, marker.viewAnnotation, new com.mapbox.maps.ViewAnnotationOptions.Builder().annotatedFeature(com.mapbox.maps.AnnotatedFeature.valueOf(marker.pointAnnotation.getGeometry())).build());
|
|
65
|
+
}
|
|
66
|
+
addMarker(marker) {
|
|
67
|
+
if (Trace.isEnabled()) {
|
|
68
|
+
CLog(CLogTypes.log, 'MarkerManager addMarker: ' + JSON.stringify(marker));
|
|
69
|
+
}
|
|
70
|
+
marker.prepareAnnotationMarker(this.pointAnnotationManager, MarkerManager.LAYER_ID);
|
|
71
|
+
this.prepareViewAnnotation(marker, (e) => {
|
|
72
|
+
// info Window tapped.
|
|
73
|
+
if (!this.onInfoWindowTapped(marker)) {
|
|
74
|
+
this.deselectMarker(marker);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
this.markerList.add(marker);
|
|
78
|
+
// this.selectMarker(marker);
|
|
79
|
+
return marker;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Build a NativeScript view to use as info window.
|
|
83
|
+
* Then attach it to Mapbox via ViewAnnotationManager.
|
|
84
|
+
*/
|
|
85
|
+
prepareViewAnnotation(marker, onInfoWindowClick) {
|
|
86
|
+
// --- Step 1: Create a NativeScript view tree
|
|
87
|
+
if (this._reusableCalloutView) {
|
|
88
|
+
const title = this._reusableCalloutView.getViewById('title');
|
|
89
|
+
title.text = marker?.title || '';
|
|
90
|
+
const subtitle = this._reusableCalloutView.getViewById('subtitle');
|
|
91
|
+
subtitle.text = marker?.snippet;
|
|
92
|
+
subtitle.visibility = marker?.snippet ? 'visible' : 'collapse';
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this._reusableCalloutView = createInfoWindowView(marker.title, marker.snippet);
|
|
96
|
+
}
|
|
97
|
+
this._reusableCalloutView._setupAsRootView(Utils.android.getApplicationContext());
|
|
98
|
+
this._reusableCalloutView.parent = Application.getRootView();
|
|
99
|
+
this._reusableCalloutView._isAddedToNativeVisualTree = true;
|
|
100
|
+
this._reusableCalloutView.callLoaded();
|
|
101
|
+
const nativeView = this._reusableCalloutView.nativeViewProtected;
|
|
102
|
+
this._reusableCalloutView.removeEventListener('tap');
|
|
103
|
+
this._reusableCalloutView.on('tap', onInfoWindowClick);
|
|
104
|
+
const frameLayout = new android.widget.FrameLayout(this._reusableCalloutView._context);
|
|
105
|
+
const layoutParams = new android.widget.FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
106
|
+
frameLayout.addView(nativeView);
|
|
107
|
+
frameLayout.setLayoutParams(layoutParams);
|
|
108
|
+
frameLayout.measure(android.view.View.MeasureSpec.makeMeasureSpec(0, android.view.View.MeasureSpec.UNSPECIFIED), android.view.View.MeasureSpec.makeMeasureSpec(0, android.view.View.MeasureSpec.UNSPECIFIED));
|
|
109
|
+
frameLayout.layout(0, 0, nativeView.getMeasuredWidth(), nativeView.getMeasuredHeight());
|
|
110
|
+
// frameLayout.setLayoutParams(new android.widget.FrameLayout.LayoutParams(nativeView.getMeasuredWidth(), nativeView.getMeasuredHeight()));
|
|
111
|
+
// --- Step 3: Prepare view annotation options
|
|
112
|
+
const ViewAnnotationAnchor = com.mapbox.maps.ViewAnnotationAnchor;
|
|
113
|
+
const ViewAnnotationAnchorConfigBuilder = com.mapbox.maps.ViewAnnotationAnchorConfig.Builder;
|
|
114
|
+
const offsetY = (marker.pointAnnotation.getIconImageBitmap()?.getHeight() ?? 0) + MarkerManager.MARKER_PADDING_PX;
|
|
115
|
+
const anchor = new ViewAnnotationAnchorConfigBuilder().anchor(ViewAnnotationAnchor.BOTTOM).offsetY(offsetY).build();
|
|
116
|
+
// marker.anchor = anchor;
|
|
117
|
+
const viewAnnotationOptions = new com.mapbox.maps.ViewAnnotationOptions.Builder()
|
|
118
|
+
.visible(java.lang.Boolean.valueOf(true))
|
|
119
|
+
// .allowOverlap(java.lang.Boolean.valueOf(true))
|
|
120
|
+
// .width(java.lang.Double.valueOf(frameLayout.getMeasuredWidth()))
|
|
121
|
+
// .height(java.lang.Double.valueOf(frameLayout.getMeasuredHeight()))
|
|
122
|
+
.allowOverlapWithPuck(java.lang.Boolean.valueOf(true))
|
|
123
|
+
.ignoreCameraPadding(java.lang.Boolean.valueOf(true))
|
|
124
|
+
// .priority(java.lang.Long.valueOf(0))
|
|
125
|
+
.selected(java.lang.Boolean.valueOf(true))
|
|
126
|
+
.annotatedFeature(com.mapbox.maps.AnnotatedFeature.valueOf(marker.pointAnnotation.getGeometry()))
|
|
127
|
+
// TODO: variableAnchors is broken for now
|
|
128
|
+
.variableAnchors(java.util.Arrays.asList([
|
|
129
|
+
anchor
|
|
130
|
+
// new ViewAnnotationAnchorConfigBuilder().anchor(ViewAnnotationAnchor.BOTTOM_RIGHT).offsetY(offsetY).build(),
|
|
131
|
+
// new ViewAnnotationAnchorConfigBuilder().anchor(ViewAnnotationAnchor.BOTTOM_LEFT).offsetY(offsetY).build()
|
|
132
|
+
]))
|
|
133
|
+
.build();
|
|
134
|
+
// --- Step 4: Add the view to Mapbox’s ViewAnnotationManager
|
|
135
|
+
com.nativescript.mapbox.ViewAnnotationManager.addViewAnnotation(this.mapView, frameLayout, viewAnnotationOptions);
|
|
136
|
+
// --- Step 5: Store references
|
|
137
|
+
marker.viewAnnotation = frameLayout;
|
|
138
|
+
marker.view = this._reusableCalloutView;
|
|
139
|
+
marker.prepared = true;
|
|
140
|
+
}
|
|
141
|
+
removeMarker(marker) {
|
|
142
|
+
if (!marker.prepared)
|
|
143
|
+
return;
|
|
144
|
+
this.markerList.delete(marker);
|
|
145
|
+
com.nativescript.mapbox.ViewAnnotationManager.removeViewAnnotation(this.mapView, marker.viewAnnotation);
|
|
146
|
+
this.pointAnnotationManager.delete(marker.pointAnnotation);
|
|
147
|
+
marker.destroy();
|
|
148
|
+
}
|
|
149
|
+
selectMarker(marker, deselectIfSelected = false, update = false) {
|
|
150
|
+
if (this.isSelected(marker) && !update) {
|
|
151
|
+
if (deselectIfSelected)
|
|
152
|
+
this.deselectMarker(marker);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (this.selectedMarker && !this.isSelected(marker)) {
|
|
156
|
+
this.deselectMarker(this.selectedMarker);
|
|
157
|
+
}
|
|
158
|
+
this.selectedMarker = marker;
|
|
159
|
+
// this.adjustViewAnnotationXOffset(marker);
|
|
160
|
+
com.nativescript.mapbox.ViewAnnotationManager.updateViewAnnotation(this.mapView, marker.viewAnnotation, new com.mapbox.maps.ViewAnnotationOptions.Builder().visible(java.lang.Boolean.valueOf(true)).selected(java.lang.Boolean.valueOf(true)).build());
|
|
161
|
+
marker.viewAnnotation.setVisibility(android.view.View.VISIBLE);
|
|
162
|
+
}
|
|
163
|
+
deselectMarker(marker) {
|
|
164
|
+
if (!this.selectedMarker || marker.pointAnnotation !== this.selectedMarker.pointAnnotation) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.selectedMarker = null;
|
|
168
|
+
const View = android.view.View;
|
|
169
|
+
const viewAnnotationOptionsBuilder = new com.mapbox.maps.ViewAnnotationOptions.Builder().selected(java.lang.Boolean.valueOf(false)).visible(java.lang.Boolean.valueOf(false));
|
|
170
|
+
// if (marker.anchor) {
|
|
171
|
+
// const anchorBuilder = marker.anchor.toBuilder().offsetX(0.0).build();
|
|
172
|
+
// viewAnnotationOptionsBuilder.variableAnchors(java.util.Collections.singletonList(anchorBuilder));
|
|
173
|
+
// }
|
|
174
|
+
com.nativescript.mapbox.ViewAnnotationManager.updateViewAnnotation(this.mapView, marker.viewAnnotation, viewAnnotationOptionsBuilder.build());
|
|
175
|
+
marker.viewAnnotation.setVisibility(View.INVISIBLE);
|
|
176
|
+
}
|
|
177
|
+
destroy() {
|
|
178
|
+
this.markerList.forEach((m) => this.removeMarker(m));
|
|
179
|
+
this.pointAnnotationManager.removeClickListener(this.onPointClickListener);
|
|
180
|
+
this.onPointClickListener = null;
|
|
181
|
+
const gesturePlugin = this.mapView.getPlugin('MAPBOX_GESTURES_PLUGIN_ID');
|
|
182
|
+
com.mapbox.maps.plugin.gestures.GesturesUtils.removeOnMapClickListener(this.map, this.onMapClickListener);
|
|
183
|
+
this.onMapClickListener = null;
|
|
184
|
+
com.nativescript.mapbox.ViewAnnotationManager.removeOnViewAnnotationUpdatedListener(this.mapView, this.onViewAnnotationUpdatedListener);
|
|
185
|
+
this.onViewAnnotationUpdatedListener = null;
|
|
186
|
+
if (this._reusableCalloutView) {
|
|
187
|
+
this._reusableCalloutView._tearDownUI();
|
|
188
|
+
this._reusableCalloutView = null;
|
|
189
|
+
}
|
|
190
|
+
this.map = null;
|
|
191
|
+
this.mapView = null;
|
|
192
|
+
}
|
|
193
|
+
updateOffsetX(marker, leftTop, width) {
|
|
194
|
+
return;
|
|
195
|
+
// if (marker.preventNextUpdateOffsetX) {
|
|
196
|
+
// marker.preventNextUpdateOffsetX = false;
|
|
197
|
+
// return;
|
|
198
|
+
// }
|
|
199
|
+
// const mapSize = this.mapView.getMapboxMap().getSize();
|
|
200
|
+
// let resultOffsetX = 0.0;
|
|
201
|
+
// if (leftTop.getX() < 0 && leftTop.getX() + width > 0) {
|
|
202
|
+
// resultOffsetX = Math.abs(leftTop.getX()) + MarkerManager.ADDITIONAL_EDGE_PADDING_PX;
|
|
203
|
+
// } else if (leftTop.getX() + width > mapSize.getWidth() && leftTop.getX() < width) {
|
|
204
|
+
// resultOffsetX = mapSize.getWidth() - leftTop.getX() - width - MarkerManager.ADDITIONAL_EDGE_PADDING_PX;
|
|
205
|
+
// }
|
|
206
|
+
// const anchor = marker.anchor ? marker.anchor.toBuilder().offsetX(resultOffsetX).build() : null;
|
|
207
|
+
// if (anchor) {
|
|
208
|
+
// const options = new com.mapbox.maps.ViewAnnotationOptions.Builder().variableAnchors(java.util.Collections.singletonList(anchor)).build();
|
|
209
|
+
// // marker.preventNextUpdateOffsetX = true;
|
|
210
|
+
// com.nativescript.mapbox.ViewAnnotationManager.updateViewAnnotation(this.mapView, marker.viewAnnotation, options);
|
|
211
|
+
// }
|
|
212
|
+
}
|
|
213
|
+
isSelected(marker) {
|
|
214
|
+
return this.selectedMarker?.pointAnnotation === marker.pointAnnotation;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
MarkerManager.MARKER_PADDING_PX = 10;
|
|
218
|
+
MarkerManager.LAYER_ID = 'annotation-layer';
|
|
219
|
+
MarkerManager.ADDITIONAL_EDGE_PADDING_PX = 20.0;
|
|
220
|
+
//# sourceMappingURL=MarkerManager.android.js.map
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativescript-community/ui-mapbox",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Interactive, thoroughly customizable maps powered by vector tiles and OpenGL.",
|
|
5
5
|
"main": "index",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "npm run tsc && npm run readme",
|
|
9
|
-
"readme": "
|
|
10
|
-
"tsc": "
|
|
11
|
-
"clean": "
|
|
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"
|
|
12
13
|
},
|
|
13
14
|
"nativescript": {
|
|
14
15
|
"platforms": {
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
},
|
|
53
54
|
"readmeFilename": "README.md",
|
|
54
55
|
"dependencies": {
|
|
55
|
-
"@nativescript-community/perms": "^
|
|
56
|
+
"@nativescript-community/perms": "^3.0.4"
|
|
56
57
|
},
|
|
57
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "7975da7394c6777e5a43c15f34c706803201f728"
|
|
58
59
|
}
|
|
@@ -1,43 +1,47 @@
|
|
|
1
1
|
repositories {
|
|
2
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
|
+
}
|
|
3
17
|
}
|
|
4
18
|
|
|
5
19
|
// see https://www.mapbox.com/android-sdk/
|
|
6
20
|
dependencies {
|
|
7
|
-
def mapboxVersion = project.hasProperty("mapboxVersion") ? project.mapboxVersion : "
|
|
8
|
-
def mapboxServicesVersion = project.hasProperty("mapboxServicesVersion") ? project.mapboxServicesVersion : "
|
|
9
|
-
// def mapboxTelemetryVersion = project.hasProperty("mapboxTelemetryVersion") ? project.mapboxTelemetryVersion : "6.1.0"
|
|
21
|
+
def mapboxVersion = project.hasProperty("mapboxVersion") ? project.mapboxVersion : "11.15.3"
|
|
22
|
+
def mapboxServicesVersion = project.hasProperty("mapboxServicesVersion") ? project.mapboxServicesVersion : "7.8.0"
|
|
10
23
|
def mapboxPluginsVersion = project.hasProperty("mapboxPluginsVersion") ? project.mapboxPluginsVersion : "v9"
|
|
11
24
|
def mapboxAnnotationPluginVersion = project.hasProperty("mapboxAnnotationPluginVersion") ? project.mapboxAnnotationPluginVersion : "0.9.0"
|
|
12
|
-
// def mapboxGesturesVersion = project.hasProperty("mapboxGesturesVersion") ? project.mapboxGesturesVersion : "0.7.0"
|
|
13
25
|
def okHttpVersion = project.hasProperty("okHttpVersion") ? project.okHttpVersion : "4.9.0"
|
|
14
|
-
implementation ("com.mapbox.mapboxsdk:mapbox-android-sdk:$mapboxVersion") {
|
|
15
|
-
// transitive=false
|
|
16
|
-
}
|
|
17
|
-
if (project.hasProperty("mapboxTelemetryVersion")) {
|
|
18
|
-
def mapboxTelemetryVersion = project.hasProperty("mapboxTelemetryVersion") ? project.mapboxTelemetryVersion : "6.1.0"
|
|
19
|
-
implementation ("com.mapbox.mapboxsdk:mapbox-android-telemetry:$mapboxTelemetryVersion")
|
|
20
|
-
}
|
|
21
|
-
// implementation ("com.mapbox.mapboxsdk:mapbox-android-telemetry:$mapboxTelemetryVersion") {
|
|
22
|
-
// transitive=false
|
|
23
|
-
// }
|
|
24
|
-
implementation ("com.mapbox.mapboxsdk:mapbox-sdk-geojson:$mapboxServicesVersion"){
|
|
25
|
-
// transitive=false
|
|
26
|
-
}
|
|
27
|
-
// implementation ("com.mapbox.mapboxsdk:mapbox-android-gestures:$mapboxGesturesVersion"){
|
|
28
|
-
// transitive=false
|
|
29
|
-
// }
|
|
30
|
-
// implementation ("com.mapbox.mapboxsdk:mapbox-sdk-services:$mapboxServicesVersion"){
|
|
31
|
-
// transitive=false
|
|
32
|
-
// }
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
27
|
+
println "com.mapbox.maps:android:$mapboxVersion"
|
|
28
|
+
|
|
29
|
+
// Core Mapbox Maps SDK v11+
|
|
30
|
+
implementation "com.mapbox.maps:android:$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"
|
|
37
39
|
|
|
38
40
|
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
|
|
39
41
|
|
|
40
|
-
|
|
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"
|
|
41
45
|
|
|
42
46
|
}
|
|
43
47
|
|
|
Binary file
|
package/platforms/ios/Podfile
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
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'
|
|
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'
|
|
Binary file
|