@nativescript-community/ui-mapbox 7.0.1 → 7.0.3

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 CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [7.0.3](https://github.com/nativescript-community/ui-mapbox/compare/v7.0.2...v7.0.3) (2025-10-29)
7
+
8
+ **Note:** Version bump only for package @nativescript-community/ui-mapbox
9
+
10
+ ## [7.0.2](https://github.com/nativescript-community/ui-mapbox/compare/v7.0.1...v7.0.2) (2025-10-28)
11
+
12
+ ### Bug Fixes
13
+
14
+ * **android:** broken build ([1587e83](https://github.com/nativescript-community/ui-mapbox/commit/1587e836ecd2d500977531d8744a276183f1ff42))
15
+
6
16
  ## [7.0.1](https://github.com/nativescript-community/ui-mapbox/compare/v7.0.0...v7.0.1) (2025-10-28)
7
17
 
8
18
  ### Bug Fixes
package/common.js CHANGED
@@ -13,7 +13,7 @@ export var CLogTypes;
13
13
  CLogTypes[CLogTypes["error"] = 3] = "error";
14
14
  })(CLogTypes || (CLogTypes = {}));
15
15
  export const CLog = (type, ...args) => {
16
- Trace.write(args.map((a) => (a && typeof a === 'object' ? JSON.stringify(a) : a)).join(' '), MapboxTraceCategory, type);
16
+ Trace.write(args.join(' '), MapboxTraceCategory, type);
17
17
  };
18
18
  // ------------------------------------------------------------
19
19
  export var MapStyle;
package/index.android.js CHANGED
@@ -472,6 +472,9 @@ export class Mapbox extends MapboxCommon {
472
472
  }
473
473
  // initialize the event handlers now that we have a constructed view.
474
474
  this.markerManager = new MarkerManager(this._mapboxMapInstance, this._mapboxViewInstance, (marker) => {
475
+ if (Trace.isEnabled()) {
476
+ CLog(CLogTypes.info, 'MarkerManager.onMarkerClicked():');
477
+ }
475
478
  const cachedMarker = this._getClickedMarkerDetails(marker);
476
479
  if (cachedMarker?.onTap) {
477
480
  const result = cachedMarker.onTap(cachedMarker);
@@ -1155,6 +1158,7 @@ export class Mapbox extends MapboxCommon {
1155
1158
  marker.android = this.markerManager.addMarker(new AndroidMarker({
1156
1159
  position: com.mapbox.geojson.Point.fromLngLat(marker.lng, marker.lat),
1157
1160
  title: marker.title,
1161
+ id: marker.id,
1158
1162
  snippet: marker.subtitle,
1159
1163
  icon: icon?.android
1160
1164
  }));
@@ -1163,7 +1167,6 @@ export class Mapbox extends MapboxCommon {
1163
1167
  this.markerManager.selectMarker(marker.android);
1164
1168
  }
1165
1169
  marker.update = (newSettings) => {
1166
- console.log('update marker', Object.keys(newSettings), newSettings);
1167
1170
  const theMarker = this._markers.find((m) => m.id === marker.id);
1168
1171
  if (theMarker) {
1169
1172
  if (newSettings.onTap) {
@@ -1201,6 +1204,9 @@ export class Mapbox extends MapboxCommon {
1201
1204
  if (!this._mapboxMapInstance) {
1202
1205
  return;
1203
1206
  }
1207
+ if (Trace.isEnabled()) {
1208
+ CLog(CLogTypes.info, '_removeMarkers: ', ids);
1209
+ }
1204
1210
  this._markers.forEach((marker) => {
1205
1211
  if (!ids || (marker && marker.id && ids.indexOf(marker.id) > -1)) {
1206
1212
  if (marker && marker.android) {
@@ -1478,7 +1484,6 @@ export class Mapbox extends MapboxCommon {
1478
1484
  }
1479
1485
  const polygonOptions = new com.mapbox.maps.plugin.annotation.generated.PolygonAnnotationOptions();
1480
1486
  const nPoints = java.util.Arrays.asList([java.util.Arrays.asList(points.map((p) => com.mapbox.geojson.Point.fromLngLat(p.lng, p.lat)))]);
1481
- console.log('add points', nPoints);
1482
1487
  polygonOptions.withPoints(nPoints);
1483
1488
  polygonOptions.withFillColor(Mapbox.getAndroidColor(options.fillColor));
1484
1489
  polygonOptions.withFillOpacity(options.fillOpacity === undefined ? 1 : options.fillOpacity);
@@ -1486,7 +1491,7 @@ export class Mapbox extends MapboxCommon {
1486
1491
  if (options.strokeColor) {
1487
1492
  polygonOptions.withFillOutlineColor(Mapbox.getAndroidColor(options.strokeColor));
1488
1493
  }
1489
- this._polylines[options.id || new Date().getTime()] = this.polygonManager.create(polygonOptions);
1494
+ this._polygons[options.id || new Date().getTime()] = this.polygonManager.create(polygonOptions);
1490
1495
  resolve();
1491
1496
  }
1492
1497
  catch (ex) {
@@ -1640,10 +1645,10 @@ export class Mapbox extends MapboxCommon {
1640
1645
  if (Trace.isEnabled()) {
1641
1646
  CLog(CLogTypes.info, 'Mapbox:setOnMapClickListener(): click event at point:', point);
1642
1647
  }
1643
- return this.checkForClickEvent({
1648
+ return (listener({
1644
1649
  lat: point.latitude(),
1645
1650
  lng: point.longitude()
1646
- });
1651
+ }) ?? true);
1647
1652
  }
1648
1653
  });
1649
1654
  com.mapbox.maps.plugin.gestures.GesturesUtils.addOnMapClickListener(this._mapboxMapInstance, this.onMapClickListener);
@@ -1670,7 +1675,7 @@ export class Mapbox extends MapboxCommon {
1670
1675
  lng: point.longitude()
1671
1676
  })
1672
1677
  });
1673
- this._getGesturesPlugin().addOnMapLongClickListener(this.onMapLongClickListener);
1678
+ com.mapbox.maps.plugin.gestures.GesturesUtils.addOnMapLongClickListener(this._mapboxMapInstance, this.onMapLongClickListener);
1674
1679
  resolve();
1675
1680
  }
1676
1681
  catch (ex) {
@@ -1789,7 +1794,7 @@ export class Mapbox extends MapboxCommon {
1789
1794
  this.onFlingListener = new com.mapbox.maps.plugin.gestures.OnFlingListener({
1790
1795
  onFling: () => listener()
1791
1796
  });
1792
- this._getGesturesPlugin().addOnFlingListener(this.onFlingListener);
1797
+ com.mapbox.maps.plugin.gestures.GesturesUtils.addOnFlingListener(this._mapboxMapInstance, this.onFlingListener);
1793
1798
  resolve();
1794
1799
  }
1795
1800
  catch (ex) {
@@ -1966,7 +1971,6 @@ export class Mapbox extends MapboxCommon {
1966
1971
  bounds: options.bounds,
1967
1972
  ...options.metadata
1968
1973
  };
1969
- console.log('downloadRegion', regionId, new com.mapbox.bindgen.Value(JSON.stringify(info)));
1970
1974
  const regionOptions = new com.mapbox.common.TileRegionLoadOptions.Builder()
1971
1975
  .geometry(bbox)
1972
1976
  .descriptors(java.util.Collections.singletonList(tilesetDescriptor))
@@ -2825,7 +2829,6 @@ export class Mapbox extends MapboxCommon {
2825
2829
  invoke: (settings) => {
2826
2830
  settings.setEnabled(true);
2827
2831
  settings.setPulsingEnabled(true);
2828
- console.log('setPuckBearingEnabled', options.cameraMode, options.renderMode, options.renderMode !== 'NORMAL', com.mapbox.maps.plugin.PuckBearing.HEADING, com.mapbox.maps.plugin.PuckBearing.COURSE);
2829
2832
  settings.setLocationPuck(com.mapbox.maps.plugin.locationcomponent.LocationComponentUtils.createDefault2DPuck(true));
2830
2833
  settings.setPuckBearingEnabled(options.renderMode !== 'NORMAL');
2831
2834
  settings.setPuckBearing(options.cameraMode?.indexOf('COMPASS') !== -1 ? com.mapbox.maps.plugin.PuckBearing.HEADING : com.mapbox.maps.plugin.PuckBearing.COURSE);
package/index.ios.js CHANGED
@@ -1314,6 +1314,7 @@ export class Mapbox extends MapboxCommon {
1314
1314
  CLog(CLogTypes.info, 'createCalloutView1():', marker.id, marker.title, !!this._reusableCalloutView);
1315
1315
  }
1316
1316
  this._reusableCalloutView.removeEventListener('tap');
1317
+ this._reusableCalloutView.nativeViewProtected?.removeFromSuperview();
1317
1318
  return this._reusableCalloutView;
1318
1319
  }
1319
1320
  async showCalloutForMarkerById(markerId) {
@@ -7,13 +7,14 @@ export declare class AndroidMarker {
7
7
  icon: android.graphics.Bitmap;
8
8
  title?: string;
9
9
  snippet?: string;
10
+ id?: string | number;
10
11
  pointAnnotation: com.mapbox.maps.plugin.annotation.generated.PointAnnotation;
11
12
  viewAnnotation: android.view.View;
12
13
  view: StackLayout;
13
14
  anchor: com.mapbox.maps.ViewAnnotationAnchorConfig;
14
15
  layerId: string;
15
- prepared: boolean;
16
16
  constructor(opts: {
17
+ id: string | number;
17
18
  position: com.mapbox.geojson.Point;
18
19
  icon: android.graphics.Bitmap;
19
20
  title?: string;
@@ -5,11 +5,11 @@ import { CLog, CLogTypes } from '../common';
5
5
  */
6
6
  export class AndroidMarker {
7
7
  constructor(opts) {
8
- this.prepared = false;
9
8
  if (!opts.title && !opts.snippet) {
10
9
  throw new Error('Marker should have either title or snippet!');
11
10
  }
12
11
  this.position = opts.position;
12
+ this.id = opts.id;
13
13
  this.icon = opts.icon;
14
14
  this.title = opts.title;
15
15
  this.snippet = opts.snippet;
@@ -23,7 +23,7 @@ export class AndroidMarker {
23
23
  this.pointAnnotation = pointAnnotationManager.create(new PointAnnotationOptions().withPoint(this.position).withIconAnchor(IconAnchor.valueOf('BOTTOM')).withIconImage(this.icon));
24
24
  this.layerId = layerId;
25
25
  if (Trace.isEnabled()) {
26
- CLog(CLogTypes.log, 'MarkerManager prepareAnnotationMarker: ' + layerId);
26
+ CLog(CLogTypes.log, 'MarkerManager prepareAnnotationMarker: ' + layerId, this.id, this.pointAnnotation);
27
27
  }
28
28
  }
29
29
  update(pointAnnotationManager) {
@@ -13,6 +13,7 @@ export declare class MarkerManager {
13
13
  private selectedMarker;
14
14
  private onInfoWindowTapped;
15
15
  private _reusableCalloutView;
16
+ private _reusableCalloutNativeView;
16
17
  private onMapClickListener;
17
18
  private onPointClickListener;
18
19
  onViewAnnotationUpdatedListener: com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener;
@@ -28,7 +29,7 @@ export declare class MarkerManager {
28
29
  prepareViewAnnotation(marker: AndroidMarker, onInfoWindowClick: any): void;
29
30
  removeMarker(marker: AndroidMarker): void;
30
31
  selectMarker(marker: AndroidMarker, deselectIfSelected?: boolean, update?: boolean): void;
31
- deselectMarker(marker: AndroidMarker): void;
32
+ deselectMarker(marker: AndroidMarker): boolean;
32
33
  destroy(): void;
33
34
  updateOffsetX(marker: AndroidMarker, leftTop: any, width: number): void;
34
35
  isSelected(marker: AndroidMarker): boolean;
@@ -6,7 +6,7 @@ import { createInfoWindowView } from './Marker.common';
6
6
  */
7
7
  export class MarkerManager {
8
8
  constructor(map, mapView, onMarkerClick, onInfoWindowClick) {
9
- this.markerList = new Set();
9
+ this.markerList = [];
10
10
  this.map = map;
11
11
  this.mapView = mapView;
12
12
  this.onInfoWindowTapped = onInfoWindowClick;
@@ -17,13 +17,19 @@ export class MarkerManager {
17
17
  // add click listeners
18
18
  this.onPointClickListener = new com.mapbox.maps.plugin.annotation.generated.OnPointAnnotationClickListener({
19
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);
20
+ const index = this.markerList.findIndex((m) => m.pointAnnotation === annotation);
21
+ if (Trace.isEnabled()) {
22
+ CLog(CLogTypes.info, 'MarkerManager.onAnnotationClick():', annotation, index, this.markerList.map((m) => m.id));
23
+ }
24
+ if (index !== -1) {
25
+ const marker = this.markerList[index];
26
+ if (Trace.isEnabled()) {
27
+ CLog(CLogTypes.info, 'MarkerManager.onAnnotationClick(): found', annotation);
28
+ }
29
+ if (onMarkerClick(marker)) {
30
+ return true;
26
31
  }
32
+ this.selectMarker(marker, true);
27
33
  }
28
34
  return true;
29
35
  }
@@ -32,17 +38,17 @@ export class MarkerManager {
32
38
  // Map click listener to deselect all markers
33
39
  this.onMapClickListener = new com.mapbox.maps.plugin.gestures.OnMapClickListener({
34
40
  onMapClick: (point) => {
35
- if (this.selectedMarker) {
36
- this.deselectMarker(this.selectedMarker);
37
- return true;
41
+ if (Trace.isEnabled()) {
42
+ CLog(CLogTypes.log, 'MarkerManager onMapClick: ', !!this.selectedMarker);
38
43
  }
39
- return false;
44
+ return this.deselectMarker(this.selectedMarker);
40
45
  }
41
46
  });
42
47
  com.mapbox.maps.plugin.gestures.GesturesUtils.addOnMapClickListener(map, this.onMapClickListener);
43
48
  }
44
49
  deselectAll() {
45
- this.markerList.forEach((marker) => this.deselectMarker(marker));
50
+ this.deselectMarker(this.selectedMarker);
51
+ // this.markerList.forEach((marker: AndroidMarker) => this.deselectMarker(marker));
46
52
  }
47
53
  adjustViewAnnotationXOffset(marker) {
48
54
  const listener = new com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener({
@@ -61,21 +67,20 @@ export class MarkerManager {
61
67
  updateMarker(marker) {
62
68
  // this.adjustViewAnnotationXOffset(marker);
63
69
  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());
70
+ if (marker.viewAnnotation) {
71
+ 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());
72
+ }
65
73
  }
66
74
  addMarker(marker) {
67
75
  if (Trace.isEnabled()) {
68
- CLog(CLogTypes.log, 'MarkerManager addMarker: ' + JSON.stringify(marker));
76
+ CLog(CLogTypes.log, 'MarkerManager addMarker: ', marker, !!this.selectedMarker);
77
+ }
78
+ if (!marker.pointAnnotation || this.markerList.findIndex((m) => m.pointAnnotation === marker.pointAnnotation) === -1) {
79
+ marker.prepareAnnotationMarker(this.pointAnnotationManager, MarkerManager.LAYER_ID);
80
+ this.deselectMarker(this.selectedMarker);
81
+ this.markerList.push(marker);
82
+ // this.selectMarker(marker);
69
83
  }
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
84
  return marker;
80
85
  }
81
86
  /**
@@ -84,6 +89,9 @@ export class MarkerManager {
84
89
  */
85
90
  prepareViewAnnotation(marker, onInfoWindowClick) {
86
91
  // --- Step 1: Create a NativeScript view tree
92
+ if (Trace.isEnabled()) {
93
+ CLog(CLogTypes.info, 'MarkerManager:prepareViewAnnotation():', this._reusableCalloutView);
94
+ }
87
95
  if (this._reusableCalloutView) {
88
96
  const title = this._reusableCalloutView.getViewById('title');
89
97
  title.text = marker?.title || '';
@@ -93,20 +101,29 @@ export class MarkerManager {
93
101
  }
94
102
  else {
95
103
  this._reusableCalloutView = createInfoWindowView(marker.title, marker.snippet);
104
+ this._reusableCalloutView._setupAsRootView(Utils.android.getApplicationContext());
105
+ this._reusableCalloutView.parent = Application.getRootView();
106
+ this._reusableCalloutView._isAddedToNativeVisualTree = true;
107
+ this._reusableCalloutView.callLoaded();
108
+ }
109
+ if (!this._reusableCalloutNativeView) {
110
+ const nativeView = this._reusableCalloutView.nativeViewProtected;
111
+ const frameLayout = new android.widget.FrameLayout(this._reusableCalloutView._context);
112
+ const layoutParams = new android.widget.FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
113
+ frameLayout.addView(nativeView);
114
+ frameLayout.setLayoutParams(layoutParams);
115
+ frameLayout.measure(android.view.View.MeasureSpec.makeMeasureSpec(0, android.view.View.MeasureSpec.UNSPECIFIED), android.view.View.MeasureSpec.makeMeasureSpec(0, android.view.View.MeasureSpec.UNSPECIFIED));
116
+ frameLayout.layout(0, 0, this._reusableCalloutView.getMeasuredWidth(), this._reusableCalloutView.getMeasuredHeight());
117
+ this._reusableCalloutNativeView = frameLayout;
118
+ }
119
+ if (this._reusableCalloutNativeView.getParent()) {
120
+ if (Trace.isEnabled()) {
121
+ CLog(CLogTypes.info, 'MarkerManager:prepareViewAnnotation(): remove from parent', this._reusableCalloutNativeView.getParent());
122
+ }
123
+ this._reusableCalloutNativeView.getParent().removeView(this._reusableCalloutNativeView);
96
124
  }
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
125
  this._reusableCalloutView.removeEventListener('tap');
103
126
  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
127
  // frameLayout.setLayoutParams(new android.widget.FrameLayout.LayoutParams(nativeView.getMeasuredWidth(), nativeView.getMeasuredHeight()));
111
128
  // --- Step 3: Prepare view annotation options
112
129
  const ViewAnnotationAnchor = com.mapbox.maps.ViewAnnotationAnchor;
@@ -132,17 +149,25 @@ export class MarkerManager {
132
149
  ]))
133
150
  .build();
134
151
  // --- Step 4: Add the view to Mapbox’s ViewAnnotationManager
135
- com.nativescript.mapbox.ViewAnnotationManager.addViewAnnotation(this.mapView, frameLayout, viewAnnotationOptions);
152
+ com.nativescript.mapbox.ViewAnnotationManager.addViewAnnotation(this.mapView, this._reusableCalloutNativeView, viewAnnotationOptions);
136
153
  // --- Step 5: Store references
137
- marker.viewAnnotation = frameLayout;
154
+ marker.viewAnnotation = this._reusableCalloutNativeView;
138
155
  marker.view = this._reusableCalloutView;
139
- marker.prepared = true;
140
156
  }
141
157
  removeMarker(marker) {
142
- if (!marker.prepared)
158
+ if (Trace.isEnabled()) {
159
+ CLog(CLogTypes.info, '_removeMarkers: ', marker.id, marker.pointAnnotation);
160
+ }
161
+ if (!marker.pointAnnotation)
143
162
  return;
144
- this.markerList.delete(marker);
145
- com.nativescript.mapbox.ViewAnnotationManager.removeViewAnnotation(this.mapView, marker.viewAnnotation);
163
+ const index = this.markerList.findIndex((m) => m.pointAnnotation === marker.pointAnnotation);
164
+ if (index !== -1) {
165
+ this.markerList.splice(index, 1);
166
+ }
167
+ if (marker.viewAnnotation) {
168
+ com.nativescript.mapbox.ViewAnnotationManager.removeViewAnnotation(this.mapView, marker.viewAnnotation);
169
+ marker.viewAnnotation = null;
170
+ }
146
171
  this.pointAnnotationManager.delete(marker.pointAnnotation);
147
172
  marker.destroy();
148
173
  }
@@ -156,23 +181,34 @@ export class MarkerManager {
156
181
  this.deselectMarker(this.selectedMarker);
157
182
  }
158
183
  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);
184
+ this.prepareViewAnnotation(marker, (e) => {
185
+ // info Window tapped.
186
+ if (!this.onInfoWindowTapped(marker)) {
187
+ this.deselectMarker(marker);
188
+ }
189
+ });
162
190
  }
163
191
  deselectMarker(marker) {
164
192
  if (!this.selectedMarker || marker.pointAnnotation !== this.selectedMarker.pointAnnotation) {
165
- return;
193
+ return false;
194
+ }
195
+ if (Trace.isEnabled()) {
196
+ CLog(CLogTypes.log, 'MarkerManager deselectMarker: ', marker, !!this.selectedMarker);
166
197
  }
167
198
  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));
199
+ // const View = android.view.View;
200
+ // const viewAnnotationOptionsBuilder = new com.mapbox.maps.ViewAnnotationOptions.Builder().selected(java.lang.Boolean.valueOf(false)).visible(java.lang.Boolean.valueOf(false));
170
201
  // if (marker.anchor) {
171
202
  // const anchorBuilder = marker.anchor.toBuilder().offsetX(0.0).build();
172
203
  // viewAnnotationOptionsBuilder.variableAnchors(java.util.Collections.singletonList(anchorBuilder));
173
204
  // }
174
- com.nativescript.mapbox.ViewAnnotationManager.updateViewAnnotation(this.mapView, marker.viewAnnotation, viewAnnotationOptionsBuilder.build());
175
- marker.viewAnnotation.setVisibility(View.INVISIBLE);
205
+ if (marker.viewAnnotation) {
206
+ com.nativescript.mapbox.ViewAnnotationManager.removeViewAnnotation(this.mapView, marker.viewAnnotation);
207
+ marker.viewAnnotation = null;
208
+ }
209
+ // com.nativescript.mapbox.ViewAnnotationManager.updateViewAnnotation(this.mapView, marker.viewAnnotation, viewAnnotationOptionsBuilder.build());
210
+ // marker.viewAnnotation.setVisibility(View.INVISIBLE);
211
+ return true;
176
212
  }
177
213
  destroy() {
178
214
  this.markerList.forEach((m) => this.removeMarker(m));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-mapbox",
3
- "version": "7.0.1",
3
+ "version": "7.0.3",
4
4
  "description": "Interactive, thoroughly customizable maps powered by vector tiles and OpenGL.",
5
5
  "main": "index",
6
6
  "typings": "index.d.ts",
@@ -55,5 +55,5 @@
55
55
  "dependencies": {
56
56
  "@nativescript-community/perms": "^3.0.4"
57
57
  },
58
- "gitHead": "c775cf24ff6f702e028f9a4fe2d562a863281eb5"
58
+ "gitHead": "8dcec4f0ac14748e1dba5701bdc53e89bd45c135"
59
59
  }
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
+
4
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
5
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
6
+
7
+ </manifest>
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,102 @@
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
+ }
@@ -0,0 +1,16 @@
1
+ <vector xmlns:android="http://schemas.android.com/apk/res/android"
2
+ android:width="40dp"
3
+ android:height="52dp"
4
+ android:viewportWidth="40"
5
+ android:viewportHeight="52">
6
+ <path
7
+ android:pathData="M11.25,39.063a8.75,2.188 0,1 0,17.5 0a8.75,2.188 0,1 0,-17.5 0z"
8
+ android:fillColor="#000000"
9
+ android:fillAlpha="0.3"/>
10
+ <path
11
+ android:pathData="M27.917,29.259C31.504,25.178 35,21.201 35,15C35,6.716 28.284,0 20,0C11.716,0 5,6.716 5,15C5,21.201 8.496,25.178 12.083,29.259C14.655,32.183 17.273,35.161 18.685,39.051C18.888,39.608 19.406,40 20,40C20.594,40 21.112,39.608 21.315,39.051C22.727,35.161 25.345,32.183 27.917,29.259Z"
12
+ android:fillColor="#EB252A"/>
13
+ <path
14
+ android:pathData="M25.5,15C25.5,18.038 23.038,20.5 20,20.5C16.962,20.5 14.5,18.038 14.5,15C14.5,11.962 16.962,9.5 20,9.5C23.038,9.5 25.5,11.962 25.5,15Z"
15
+ android:fillColor="#ffffff"/>
16
+ </vector>