@nativescript-community/ui-mapbox 7.0.0-alpha.14.3191a7b → 7.0.1
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 +13 -0
- package/common.d.ts +18 -2
- package/common.js +9 -2
- package/expression/expression-parser.ios.d.ts +2 -2
- package/expression/expression-parser.ios.js +28 -13
- package/index.android.d.ts +5 -12
- package/index.android.js +11 -97
- package/index.ios.d.ts +68 -241
- package/index.ios.js +1171 -2001
- package/layers/layer-factory.ios.d.ts +7 -7
- package/layers/layer-factory.ios.js +46 -100
- 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 +0 -7
- package/markers/Marker.android.js +7 -81
- package/markers/Marker.common.d.ts +2 -0
- package/markers/Marker.common.js +31 -0
- package/markers/MarkerManager.android.d.ts +7 -0
- package/markers/MarkerManager.android.js +88 -22
- package/package.json +3 -3
- package/platforms/ios/Podfile +3 -1
- package/platforms/ios/Resources/default_pin.png +0 -0
- package/platforms/ios/src/MapboxBridge.swift +1505 -0
- package/platforms/ios/src/NativeExpressionParser.swift +33 -0
- package/platforms/ios/src/NativeLayerFactory.swift +108 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/typings/Mapbox.ios.d.ts +2 -3242
- package/typings/mapbox.android.d.ts +7177 -5481
- package/typings/mapbox.bridge.ios.d.ts +128 -0
- package/platforms/android/ui_mapbox.aar +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Trace } from '@nativescript/core';
|
|
1
|
+
import { Application, Trace, Utils } from '@nativescript/core';
|
|
2
2
|
import { CLog, CLogTypes } from '../common';
|
|
3
|
+
import { createInfoWindowView } from './Marker.common';
|
|
3
4
|
/**
|
|
4
5
|
* MarkerManager (Native Android Mapbox SDK version)
|
|
5
6
|
*/
|
|
@@ -58,7 +59,7 @@ export class MarkerManager {
|
|
|
58
59
|
com.nativescript.mapbox.ViewAnnotationManager.addOnViewAnnotationUpdatedListener(this.mapView, listener);
|
|
59
60
|
}
|
|
60
61
|
updateMarker(marker) {
|
|
61
|
-
this.adjustViewAnnotationXOffset(marker);
|
|
62
|
+
// this.adjustViewAnnotationXOffset(marker);
|
|
62
63
|
marker.update(this.pointAnnotationManager);
|
|
63
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());
|
|
64
65
|
}
|
|
@@ -67,7 +68,7 @@ export class MarkerManager {
|
|
|
67
68
|
CLog(CLogTypes.log, 'MarkerManager addMarker: ' + JSON.stringify(marker));
|
|
68
69
|
}
|
|
69
70
|
marker.prepareAnnotationMarker(this.pointAnnotationManager, MarkerManager.LAYER_ID);
|
|
70
|
-
|
|
71
|
+
this.prepareViewAnnotation(marker, (e) => {
|
|
71
72
|
// info Window tapped.
|
|
72
73
|
if (!this.onInfoWindowTapped(marker)) {
|
|
73
74
|
this.deselectMarker(marker);
|
|
@@ -77,6 +78,66 @@ export class MarkerManager {
|
|
|
77
78
|
// this.selectMarker(marker);
|
|
78
79
|
return marker;
|
|
79
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
|
+
}
|
|
80
141
|
removeMarker(marker) {
|
|
81
142
|
if (!marker.prepared)
|
|
82
143
|
return;
|
|
@@ -95,7 +156,7 @@ export class MarkerManager {
|
|
|
95
156
|
this.deselectMarker(this.selectedMarker);
|
|
96
157
|
}
|
|
97
158
|
this.selectedMarker = marker;
|
|
98
|
-
this.adjustViewAnnotationXOffset(marker);
|
|
159
|
+
// this.adjustViewAnnotationXOffset(marker);
|
|
99
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());
|
|
100
161
|
marker.viewAnnotation.setVisibility(android.view.View.VISIBLE);
|
|
101
162
|
}
|
|
@@ -106,10 +167,10 @@ export class MarkerManager {
|
|
|
106
167
|
this.selectedMarker = null;
|
|
107
168
|
const View = android.view.View;
|
|
108
169
|
const viewAnnotationOptionsBuilder = new com.mapbox.maps.ViewAnnotationOptions.Builder().selected(java.lang.Boolean.valueOf(false)).visible(java.lang.Boolean.valueOf(false));
|
|
109
|
-
if (marker.anchor) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
170
|
+
// if (marker.anchor) {
|
|
171
|
+
// const anchorBuilder = marker.anchor.toBuilder().offsetX(0.0).build();
|
|
172
|
+
// viewAnnotationOptionsBuilder.variableAnchors(java.util.Collections.singletonList(anchorBuilder));
|
|
173
|
+
// }
|
|
113
174
|
com.nativescript.mapbox.ViewAnnotationManager.updateViewAnnotation(this.mapView, marker.viewAnnotation, viewAnnotationOptionsBuilder.build());
|
|
114
175
|
marker.viewAnnotation.setVisibility(View.INVISIBLE);
|
|
115
176
|
}
|
|
@@ -122,33 +183,38 @@ export class MarkerManager {
|
|
|
122
183
|
this.onMapClickListener = null;
|
|
123
184
|
com.nativescript.mapbox.ViewAnnotationManager.removeOnViewAnnotationUpdatedListener(this.mapView, this.onViewAnnotationUpdatedListener);
|
|
124
185
|
this.onViewAnnotationUpdatedListener = null;
|
|
186
|
+
if (this._reusableCalloutView) {
|
|
187
|
+
this._reusableCalloutView._tearDownUI();
|
|
188
|
+
this._reusableCalloutView = null;
|
|
189
|
+
}
|
|
125
190
|
this.map = null;
|
|
126
191
|
this.mapView = null;
|
|
127
192
|
}
|
|
128
193
|
updateOffsetX(marker, leftTop, width) {
|
|
194
|
+
return;
|
|
129
195
|
// if (marker.preventNextUpdateOffsetX) {
|
|
130
196
|
// marker.preventNextUpdateOffsetX = false;
|
|
131
197
|
// return;
|
|
132
198
|
// }
|
|
133
|
-
const mapSize = this.mapView.getMapboxMap().getSize();
|
|
134
|
-
let resultOffsetX = 0.0;
|
|
135
|
-
if (leftTop.getX() < 0 && leftTop.getX() + width > 0) {
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
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
|
+
// }
|
|
147
212
|
}
|
|
148
213
|
isSelected(marker) {
|
|
149
214
|
return this.selectedMarker?.pointAnnotation === marker.pointAnnotation;
|
|
150
215
|
}
|
|
151
216
|
}
|
|
217
|
+
MarkerManager.MARKER_PADDING_PX = 10;
|
|
152
218
|
MarkerManager.LAYER_ID = 'annotation-layer';
|
|
153
219
|
MarkerManager.ADDITIONAL_EDGE_PADDING_PX = 20.0;
|
|
154
220
|
//# sourceMappingURL=MarkerManager.android.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativescript-community/ui-mapbox",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Interactive, thoroughly customizable maps powered by vector tiles and OpenGL.",
|
|
5
5
|
"main": "index",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"readmeFilename": "README.md",
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@nativescript-community/perms": "^
|
|
56
|
+
"@nativescript-community/perms": "^3.0.4"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "c775cf24ff6f702e028f9a4fe2d562a863281eb5"
|
|
59
59
|
}
|
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
|