@nativescript-community/ui-mapbox 6.2.14 → 6.2.19
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 +40 -0
- package/blueprint.md +922 -0
- package/common.d.ts +3 -0
- package/common.js +4 -1
- package/index.android.d.ts +3 -1
- package/index.android.js +34 -4
- package/index.ios.d.ts +3 -1
- package/index.ios.js +36 -241
- package/package.json +2 -2
- package/platforms/android/ui_mapbox.aar +0 -0
package/common.d.ts
CHANGED
|
@@ -292,6 +292,7 @@ export interface MapboxApi {
|
|
|
292
292
|
changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode, nativeMap?: any): void;
|
|
293
293
|
forceUserLocationUpdate(location: any, nativeMap?: any): void;
|
|
294
294
|
trackUser(options: TrackUserOptions, nativeMap?: any): Promise<void>;
|
|
295
|
+
getUserLocationCameraMode(nativeMap?: any): UserLocationCameraMode;
|
|
295
296
|
addSource(id: string, options: AddSourceOptions, nativeMapView?: any): Promise<any>;
|
|
296
297
|
updateSource(id: string, options: UpdateSourceOptions, nativeMapView?: any): Promise<any>;
|
|
297
298
|
removeSource(id: string, nativeMap?: any): Promise<any>;
|
|
@@ -393,6 +394,7 @@ export interface MapboxViewApi {
|
|
|
393
394
|
setTilt(options: SetTiltOptions): Promise<any>;
|
|
394
395
|
getUserLocation(): Promise<UserLocation>;
|
|
395
396
|
trackUser(options: TrackUserOptions): Promise<any>;
|
|
397
|
+
getUserLocationCameraMode(nativeMap?: any): UserLocationCameraMode;
|
|
396
398
|
showUserLocationMarker(options: any): void;
|
|
397
399
|
hideUserLocationMarker(options: any): void;
|
|
398
400
|
changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode): void;
|
|
@@ -461,6 +463,7 @@ export declare abstract class MapboxViewCommonBase extends ContentView implement
|
|
|
461
463
|
changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode): void;
|
|
462
464
|
forceUserLocationUpdate(location: any): void;
|
|
463
465
|
trackUser(options: TrackUserOptions): Promise<any>;
|
|
466
|
+
getUserLocationCameraMode(): UserLocationCameraMode;
|
|
464
467
|
addSource(id: string, options: AddSourceOptions): Promise<any>;
|
|
465
468
|
updateSource(id: string, options: UpdateSourceOptions): Promise<any>;
|
|
466
469
|
removeSource(id: string): Promise<any>;
|
package/common.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContentView, Property, Trace, booleanConverter } from '@nativescript/core';
|
|
1
|
+
import { Color, ContentView, ImageSource, Property, Trace, booleanConverter } from '@nativescript/core';
|
|
2
2
|
export * from './geo.utils';
|
|
3
3
|
export * from './expression/expression-parser';
|
|
4
4
|
export * from './layers/layer-factory';
|
|
@@ -158,6 +158,9 @@ export class MapboxViewCommonBase extends ContentView {
|
|
|
158
158
|
trackUser(options) {
|
|
159
159
|
return this.mapbox.trackUser(options, this.getNativeMapView());
|
|
160
160
|
}
|
|
161
|
+
getUserLocationCameraMode() {
|
|
162
|
+
return this.mapbox.getUserLocationCameraMode(this.getNativeMapView());
|
|
163
|
+
}
|
|
161
164
|
addSource(id, options) {
|
|
162
165
|
return this.mapbox.addSource(id, options, this.getNativeMapView());
|
|
163
166
|
}
|
package/index.android.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
|
|
|
109
109
|
deleteOfflineRegion(options: DeleteOfflineRegionOptions): Promise<void>;
|
|
110
110
|
_getOfflineManager(): any;
|
|
111
111
|
addExtrusion(options: AddExtrusionOptions, nativeMap?: any): Promise<void>;
|
|
112
|
-
updateSource(id: string, options: UpdateSourceOptions, nativeMap?: any): Promise<
|
|
112
|
+
updateSource(id: string, options: UpdateSourceOptions, nativeMap?: any): Promise<void>;
|
|
113
113
|
addSource(id: string, options: AddSourceOptions, nativeMap?: any): Promise<void>;
|
|
114
114
|
removeSource(id: string, nativeMap?: any): Promise<void>;
|
|
115
115
|
addLayer(style: any, belowLayerId?: string, nativeMap?: any): Promise<void>;
|
|
@@ -122,6 +122,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
|
|
|
122
122
|
_getMapboxMapOptions(settings: any): com.mapbox.mapboxsdk.maps.MapboxMapOptions;
|
|
123
123
|
_stringToCameraMode(mode: UserLocationCameraMode): any;
|
|
124
124
|
_stringToRenderMode(mode: any): any;
|
|
125
|
+
_convertCameraMode(mode: any): UserLocationCameraMode;
|
|
125
126
|
_fineLocationPermissionGranted(): boolean;
|
|
126
127
|
_getRegionName(offlineRegion: com.mapbox.mapboxsdk.offline.OfflineRegion): string;
|
|
127
128
|
_getRegionMetadata(offlineRegion: com.mapbox.mapboxsdk.offline.OfflineRegion): any;
|
|
@@ -142,4 +143,5 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
|
|
|
142
143
|
x: number;
|
|
143
144
|
y: number;
|
|
144
145
|
}): LatLng;
|
|
146
|
+
getUserLocationCameraMode(nativeMap?: any): UserLocationCameraMode;
|
|
145
147
|
}
|
package/index.android.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { request } from '@nativescript-community/perms';
|
|
2
|
-
import { AndroidApplication, Application, Color, File, Http, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
|
|
2
|
+
import { AndroidApplication, Application, Color, File, Http, Image, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
|
|
3
3
|
import { ExpressionParser } from './expression/expression-parser';
|
|
4
4
|
import { Layer, LayerFactory } from './layers/layer-factory';
|
|
5
|
-
import { CLog, CLogTypes, MapStyle, MapboxCommon, MapboxViewBase, telemetryProperty } from './common';
|
|
5
|
+
import { CLog, CLogTypes, MapStyle, MapboxCommon, MapboxTraceCategory, MapboxViewBase, telemetryProperty } from './common';
|
|
6
6
|
export * from './common';
|
|
7
7
|
function _getLocation(loc) {
|
|
8
8
|
if (loc === null) {
|
|
@@ -843,13 +843,13 @@ export class Mapbox extends MapboxCommon {
|
|
|
843
843
|
markerOptions.setPosition(new com.mapbox.mapboxsdk.geometry.LatLng(parseFloat(marker.lat), parseFloat(marker.lng)));
|
|
844
844
|
if (marker.icon) {
|
|
845
845
|
if (marker.icon.startsWith('res://')) {
|
|
846
|
-
let cached = this.iconCache[marker.
|
|
846
|
+
let cached = this.iconCache[marker.icon];
|
|
847
847
|
if (!cached) {
|
|
848
848
|
const resourcename = marker.icon.substring(6);
|
|
849
849
|
const res = Utils.ad.getApplicationContext().getResources();
|
|
850
850
|
const identifier = res.getIdentifier(resourcename, 'drawable', Utils.ad.getApplication().getPackageName());
|
|
851
851
|
if (identifier !== 0) {
|
|
852
|
-
cached = this.iconCache[marker.
|
|
852
|
+
cached = this.iconCache[marker.icon] = iconFactory.fromResource(identifier);
|
|
853
853
|
}
|
|
854
854
|
}
|
|
855
855
|
if (cached) {
|
|
@@ -1786,6 +1786,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
1786
1786
|
case 'geojson':
|
|
1787
1787
|
const geoJsonString = JSON.stringify(options.data);
|
|
1788
1788
|
source.setGeoJson(geoJsonString);
|
|
1789
|
+
resolve();
|
|
1789
1790
|
break;
|
|
1790
1791
|
default:
|
|
1791
1792
|
reject('Invalid source type: ' + options['type']);
|
|
@@ -2187,6 +2188,26 @@ export class Mapbox extends MapboxCommon {
|
|
|
2187
2188
|
}
|
|
2188
2189
|
return renderMode;
|
|
2189
2190
|
}
|
|
2191
|
+
_convertCameraMode(mode) {
|
|
2192
|
+
const modeRef = com.mapbox.mapboxsdk.location.modes.CameraMode;
|
|
2193
|
+
switch (mode) {
|
|
2194
|
+
case modeRef.NONE:
|
|
2195
|
+
return "NONE";
|
|
2196
|
+
case modeRef.NONE_COMPASS:
|
|
2197
|
+
return "NONE_COMPASS";
|
|
2198
|
+
case modeRef.NONE_GPS:
|
|
2199
|
+
return "NONE_GPS";
|
|
2200
|
+
case modeRef.TRACKING:
|
|
2201
|
+
return "TRACKING";
|
|
2202
|
+
case modeRef.TRACKING_COMPASS:
|
|
2203
|
+
return "TRACKING_COMPASS";
|
|
2204
|
+
case modeRef.TRACKING_GPS:
|
|
2205
|
+
return "TRACKING_GPS";
|
|
2206
|
+
case modeRef.TRACKING_GPS_NORTH:
|
|
2207
|
+
return "TRACKING_GPS_NORTH";
|
|
2208
|
+
}
|
|
2209
|
+
return "NONE";
|
|
2210
|
+
}
|
|
2190
2211
|
_fineLocationPermissionGranted() {
|
|
2191
2212
|
let hasPermission = android.os.Build.VERSION.SDK_INT < 23;
|
|
2192
2213
|
if (!hasPermission) {
|
|
@@ -2501,5 +2522,14 @@ export class Mapbox extends MapboxCommon {
|
|
|
2501
2522
|
lng: coordinate.getLongitude()
|
|
2502
2523
|
};
|
|
2503
2524
|
}
|
|
2525
|
+
getUserLocationCameraMode(nativeMap) {
|
|
2526
|
+
if (!this._mapboxMapInstance) {
|
|
2527
|
+
return "NONE";
|
|
2528
|
+
}
|
|
2529
|
+
if (!this._locationComponent) {
|
|
2530
|
+
return "NONE";
|
|
2531
|
+
}
|
|
2532
|
+
return this._convertCameraMode(this._locationComponent.getCameraMode());
|
|
2533
|
+
}
|
|
2504
2534
|
}
|
|
2505
2535
|
//# sourceMappingURL=index.android.js.map
|
package/index.ios.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
|
|
|
53
53
|
getUserLocation(nativeMap?: any): Promise<UserLocation>;
|
|
54
54
|
_stringToCameraMode(mode: UserLocationCameraMode): any;
|
|
55
55
|
_stringToRenderMode(mode: any): any;
|
|
56
|
+
_convertCameraMode(mode: MGLUserTrackingMode): UserLocationCameraMode;
|
|
56
57
|
showUserLocationMarker(options: any, nativeMap?: any): Promise<void>;
|
|
57
58
|
hideUserLocationMarker(nativeMap?: any): Promise<void>;
|
|
58
59
|
changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode, nativeMap?: any): Promise<void>;
|
|
@@ -81,7 +82,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
|
|
|
81
82
|
listOfflineRegions(options?: ListOfflineRegionsOptions): Promise<OfflineRegion[]>;
|
|
82
83
|
deleteOfflineRegion(options: DeleteOfflineRegionOptions): Promise<void>;
|
|
83
84
|
addExtrusion(options: AddExtrusionOptions, nativeMap?: any): Promise<void>;
|
|
84
|
-
updateSource(id: string, options: UpdateSourceOptions, nativeMap?: any): Promise<
|
|
85
|
+
updateSource(id: string, options: UpdateSourceOptions, nativeMap?: any): Promise<void>;
|
|
85
86
|
addSource(id: string, options: AddSourceOptions, nativeMap?: any): Promise<void>;
|
|
86
87
|
removeSource(id: string, nativeMap?: any): Promise<void>;
|
|
87
88
|
addLayer(style: any, belowLayerId?: string, nativeMapView?: any): Promise<void>;
|
|
@@ -99,4 +100,5 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
|
|
|
99
100
|
x: number;
|
|
100
101
|
y: number;
|
|
101
102
|
}): LatLng;
|
|
103
|
+
getUserLocationCameraMode(nativeMap?: any): UserLocationCameraMode;
|
|
102
104
|
}
|
package/index.ios.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Color, File, Http, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
|
|
2
|
-
import { CLog, CLogTypes, MapStyle, MapboxCommon, MapboxViewBase, telemetryProperty } from './common';
|
|
2
|
+
import { CLog, CLogTypes, MapStyle, MapboxCommon, MapboxTraceCategory, MapboxViewBase, telemetryProperty } from './common';
|
|
3
3
|
import { Layer, LayerFactory } from './layers/layer-factory';
|
|
4
4
|
import { ExpressionParser } from './expression/expression-parser';
|
|
5
5
|
var MGLMapViewDelegateImpl = /** @class */ (function (_super) {
|
|
@@ -42,7 +42,7 @@ var MGLMapViewDelegateImpl = /** @class */ (function (_super) {
|
|
|
42
42
|
* set user location marker modes
|
|
43
43
|
*/
|
|
44
44
|
MGLMapViewDelegateImpl.prototype.changeUserLocationRenderMode = function (userLocationRenderMode) {
|
|
45
|
-
|
|
45
|
+
// nothing to do here
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
48
|
* set the camera changd listener callback
|
|
@@ -234,19 +234,6 @@ var MGLMapViewDelegateImpl = /** @class */ (function (_super) {
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
|
-
/**
|
|
238
|
-
* override the standard location marker
|
|
239
|
-
*/
|
|
240
|
-
MGLMapViewDelegateImpl.prototype.mapViewViewForAnnotation = function (mapView, annotation) {
|
|
241
|
-
if (Trace.isEnabled()) {
|
|
242
|
-
CLog(CLogTypes.info, 'MGLMapViewDelegateImpl::mapViewViewForAnnotation() top');
|
|
243
|
-
}
|
|
244
|
-
if (annotation.isKindOfClass(MGLUserLocation.class())) {
|
|
245
|
-
this.userLocationAnnotationView = CustomUserLocationAnnotationView.alloc().init();
|
|
246
|
-
return this.userLocationAnnotationView;
|
|
247
|
-
}
|
|
248
|
-
return null;
|
|
249
|
-
};
|
|
250
237
|
MGLMapViewDelegateImpl.prototype.mapViewRegionIsChangingWithReason = function (mapView, reason) {
|
|
251
238
|
if (Trace.isEnabled()) {
|
|
252
239
|
CLog(CLogTypes.info, 'MGLMapViewDelegateImpl::mapViewRegionIsChanging()');
|
|
@@ -463,9 +450,6 @@ const _getMapStyle = (input) => {
|
|
|
463
450
|
return MGLStyle.streetsStyleURL;
|
|
464
451
|
}
|
|
465
452
|
};
|
|
466
|
-
function _getTrackingMode(input) {
|
|
467
|
-
return 0;
|
|
468
|
-
}
|
|
469
453
|
function _getLocation(loc) {
|
|
470
454
|
if (loc === null) {
|
|
471
455
|
return null;
|
|
@@ -661,214 +645,6 @@ export class MapboxView extends MapboxViewBase {
|
|
|
661
645
|
NSUserDefaults.standardUserDefaults.setBoolForKey(false, 'MGLMapboxMetricsEnabled');
|
|
662
646
|
}
|
|
663
647
|
}
|
|
664
|
-
var CustomUserLocationAnnotationView = /** @class */ (function (_super) {
|
|
665
|
-
__extends(CustomUserLocationAnnotationView, _super);
|
|
666
|
-
function CustomUserLocationAnnotationView() {
|
|
667
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
668
|
-
}
|
|
669
|
-
/**
|
|
670
|
-
* init
|
|
671
|
-
*
|
|
672
|
-
* @link https://docs.nativescript.org/core-concepts/ios-runtime/HelloWorld
|
|
673
|
-
*/
|
|
674
|
-
CustomUserLocationAnnotationView.prototype.init = function () {
|
|
675
|
-
this.size = 48;
|
|
676
|
-
_super.prototype.initWithFrame.call(this, CGRectMake(0, 0, this.size, this.size));
|
|
677
|
-
this.renderModeChanged = true;
|
|
678
|
-
this.userLocationRenderMode = 'NORMAL';
|
|
679
|
-
return this;
|
|
680
|
-
};
|
|
681
|
-
/**
|
|
682
|
-
* update
|
|
683
|
-
*
|
|
684
|
-
* The note from the Objective-C sample indicates this method may be called quite
|
|
685
|
-
* often so it needs to be kept lightweight.
|
|
686
|
-
*/
|
|
687
|
-
CustomUserLocationAnnotationView.prototype.update = function () {
|
|
688
|
-
if (CLLocationCoordinate2DIsValid(this.userLocation.coordinate)) {
|
|
689
|
-
// if it's the first time here, setup the layers that make up the
|
|
690
|
-
// location marker.
|
|
691
|
-
if (!this.dot) {
|
|
692
|
-
this.drawNonTrackingLocationMarker();
|
|
693
|
-
}
|
|
694
|
-
if (this.userLocationRenderMode === 'GPS') {
|
|
695
|
-
this.updateHeading();
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
};
|
|
699
|
-
/**
|
|
700
|
-
* Draw the GPS tracking arrow.
|
|
701
|
-
*
|
|
702
|
-
* @link https://docs.nativescript.org/ns-framework-modules/color
|
|
703
|
-
*/
|
|
704
|
-
CustomUserLocationAnnotationView.prototype.drawTrackingLocationMarker = function () {
|
|
705
|
-
if (Trace.isEnabled()) {
|
|
706
|
-
CLog(CLogTypes.info, 'CustomerUserLocationAnnotatinView::drawTrackingLocationMarker()');
|
|
707
|
-
}
|
|
708
|
-
this.drawTrackingDot();
|
|
709
|
-
this.drawArrow();
|
|
710
|
-
}; // end of setupLayers()
|
|
711
|
-
/**
|
|
712
|
-
* draw the non-tracking marker
|
|
713
|
-
*/
|
|
714
|
-
CustomUserLocationAnnotationView.prototype.drawNonTrackingLocationMarker = function () {
|
|
715
|
-
if (Trace.isEnabled()) {
|
|
716
|
-
CLog(CLogTypes.info, 'CustomerUserLocationAnnotatinView::drawNonTrackingLocationMarker()');
|
|
717
|
-
}
|
|
718
|
-
this.drawNonTrackingDot();
|
|
719
|
-
if (this.arrow) {
|
|
720
|
-
this.arrow.removeFromSuperlayer();
|
|
721
|
-
this.arrow = null;
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
/**
|
|
725
|
-
* draw the tracking dot.
|
|
726
|
-
*/
|
|
727
|
-
CustomUserLocationAnnotationView.prototype.drawTrackingDot = function () {
|
|
728
|
-
this.size = 48;
|
|
729
|
-
// we need to adjust the size of the bounds of the marker. The Tracking marker
|
|
730
|
-
// is larger than the non tracking marker.
|
|
731
|
-
this.bounds = CGRectMake(0, 0, this.size, this.size);
|
|
732
|
-
var dot = CALayer.layer();
|
|
733
|
-
dot.frame = this.bounds;
|
|
734
|
-
// user corner radius to turn the layer into a circle
|
|
735
|
-
dot.cornerRadius = this.size / 2;
|
|
736
|
-
dot.backgroundColor = this.tintColor.CGColor;
|
|
737
|
-
dot.borderWidth = 4;
|
|
738
|
-
var whiteColor = new Color('#FFFFFF');
|
|
739
|
-
dot.borderColor = whiteColor.ios.CGColor;
|
|
740
|
-
if (!this.dot) {
|
|
741
|
-
this.layer.addSublayer(dot);
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
this.layer.replaceSublayerWith(this.dot, dot);
|
|
745
|
-
}
|
|
746
|
-
// QUESTION: does GC catch this?
|
|
747
|
-
this.dot = dot;
|
|
748
|
-
};
|
|
749
|
-
/**
|
|
750
|
-
* draw the non-tracking dot.
|
|
751
|
-
*/
|
|
752
|
-
CustomUserLocationAnnotationView.prototype.drawNonTrackingDot = function () {
|
|
753
|
-
this.size = 24;
|
|
754
|
-
this.bounds = CGRectMake(0, 0, this.size, this.size);
|
|
755
|
-
var dot = CALayer.layer();
|
|
756
|
-
dot.frame = this.bounds;
|
|
757
|
-
// user corner radius to turn the layer into a circle
|
|
758
|
-
dot.cornerRadius = this.size / 2;
|
|
759
|
-
dot.backgroundColor = this.tintColor.CGColor;
|
|
760
|
-
dot.borderWidth = 1;
|
|
761
|
-
var whiteColor = new Color('#FFFFFF');
|
|
762
|
-
dot.borderColor = whiteColor.ios.CGColor;
|
|
763
|
-
if (!this.dot) {
|
|
764
|
-
this.layer.addSublayer(dot);
|
|
765
|
-
}
|
|
766
|
-
else {
|
|
767
|
-
this.layer.replaceSublayerWith(this.dot, dot);
|
|
768
|
-
}
|
|
769
|
-
// QUESTION: does GC catch this?
|
|
770
|
-
this.dot = dot;
|
|
771
|
-
};
|
|
772
|
-
/**
|
|
773
|
-
* draw an arrow
|
|
774
|
-
*/
|
|
775
|
-
CustomUserLocationAnnotationView.prototype.drawArrow = function () {
|
|
776
|
-
var arrow = CAShapeLayer.layer();
|
|
777
|
-
arrow.path = this.arrowPath();
|
|
778
|
-
arrow.frame = CGRectMake(0, 0, this.size / 2, this.size / 2);
|
|
779
|
-
arrow.position = CGPointMake(CGRectGetMidX(this.dot.frame), CGRectGetMidY(this.dot.frame));
|
|
780
|
-
arrow.fillColor = this.dot.borderColor;
|
|
781
|
-
if (!this.arrow) {
|
|
782
|
-
this.layer.addSublayer(arrow);
|
|
783
|
-
}
|
|
784
|
-
else {
|
|
785
|
-
this.layer.replaceSublayerWith(this.arrow, arrow);
|
|
786
|
-
}
|
|
787
|
-
// QUESTION: Does GC catch this?
|
|
788
|
-
this.arrow = arrow;
|
|
789
|
-
};
|
|
790
|
-
/**
|
|
791
|
-
* update arrow heading
|
|
792
|
-
*
|
|
793
|
-
* @link https://docs.nativescript.org/core-concepts/ios-runtime/types/C-Functions
|
|
794
|
-
*/
|
|
795
|
-
CustomUserLocationAnnotationView.prototype.updateHeading = function () {
|
|
796
|
-
// just to avoid a possible race condition where the arrow isnt' drawn yet
|
|
797
|
-
if (!this.arrow) {
|
|
798
|
-
return;
|
|
799
|
-
}
|
|
800
|
-
if (typeof this.userLocation == 'undefined') {
|
|
801
|
-
return;
|
|
802
|
-
}
|
|
803
|
-
if (typeof this.userLocation.heading == 'undefined' || this.userLocation.heading === null) {
|
|
804
|
-
return;
|
|
805
|
-
}
|
|
806
|
-
if (typeof this.userLocation.heading.trueHeading == 'undefined' || this.userLocation.heading.trueHeading === null) {
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
if (this.userLocation.heading.trueHeading > 0) {
|
|
810
|
-
this.arrow.hidden = false;
|
|
811
|
-
// get the difference between the map's current direction and the
|
|
812
|
-
// user's heading, then convert it from degrees to radians
|
|
813
|
-
//
|
|
814
|
-
// The original Objective-C example uses the inline C function MGLRadiansFromDegrees but because
|
|
815
|
-
// it's declared as inline it is not available for NativeScript. See linked article above.
|
|
816
|
-
// let rotation : number = MGLRadiansFromDegrees( this.mapView.direction - this.userLocation.heading.trueHeading );
|
|
817
|
-
var degrees = this.mapView.direction - this.userLocation.heading.trueHeading;
|
|
818
|
-
// in radians
|
|
819
|
-
var rotation = (degrees * Math.PI) / 180;
|
|
820
|
-
rotation = -rotation;
|
|
821
|
-
// if the difference would be perceptible, rotate the arrow.
|
|
822
|
-
if (fabs(rotation) > 0.01) {
|
|
823
|
-
// Disable implicit animations of this rotation, which reduces lag between updates
|
|
824
|
-
CATransaction.begin();
|
|
825
|
-
CATransaction.setDisableActions(true);
|
|
826
|
-
this.arrow.setAffineTransform(CGAffineTransformRotate(CGAffineTransformIdentity, rotation));
|
|
827
|
-
CATransaction.commit();
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
else {
|
|
831
|
-
this.arrow.hidden = true;
|
|
832
|
-
}
|
|
833
|
-
};
|
|
834
|
-
/**
|
|
835
|
-
* Calculate the vector path for an arrow
|
|
836
|
-
*/
|
|
837
|
-
CustomUserLocationAnnotationView.prototype.arrowPath = function () {
|
|
838
|
-
var max = this.size / 2;
|
|
839
|
-
var pad = 3;
|
|
840
|
-
var top = CGPointMake(max * 0.5, 0);
|
|
841
|
-
var left = CGPointMake(0 + pad, max - pad);
|
|
842
|
-
var right = CGPointMake(max - pad, max - pad);
|
|
843
|
-
var center = CGPointMake(max * 0.5, max * 0.6);
|
|
844
|
-
var bezierPath = UIBezierPath.bezierPath();
|
|
845
|
-
bezierPath.moveToPoint(top);
|
|
846
|
-
bezierPath.addLineToPoint(left);
|
|
847
|
-
bezierPath.addLineToPoint(center);
|
|
848
|
-
bezierPath.addLineToPoint(right);
|
|
849
|
-
bezierPath.addLineToPoint(top);
|
|
850
|
-
bezierPath.closePath();
|
|
851
|
-
return bezierPath.CGPath;
|
|
852
|
-
};
|
|
853
|
-
/**
|
|
854
|
-
* change Render mode
|
|
855
|
-
*
|
|
856
|
-
* @param {string} renderMode
|
|
857
|
-
*/
|
|
858
|
-
CustomUserLocationAnnotationView.prototype.changeUserLocationRenderMode = function (renderMode) {
|
|
859
|
-
if (Trace.isEnabled()) {
|
|
860
|
-
CLog(CLogTypes.info, "CustomUserLocationAnnotatinView::changeUserLocationRenderMode(): changing mode to '" + renderMode + "'");
|
|
861
|
-
}
|
|
862
|
-
this.userLocationRenderMode = renderMode;
|
|
863
|
-
if (renderMode === 'GPS') {
|
|
864
|
-
this.drawTrackingLocationMarker();
|
|
865
|
-
}
|
|
866
|
-
else {
|
|
867
|
-
this.drawNonTrackingLocationMarker();
|
|
868
|
-
}
|
|
869
|
-
};
|
|
870
|
-
return CustomUserLocationAnnotationView;
|
|
871
|
-
}(MGLUserLocationAnnotationView));
|
|
872
648
|
export class Mapbox extends MapboxCommon {
|
|
873
649
|
constructor() {
|
|
874
650
|
super(...arguments);
|
|
@@ -1333,27 +1109,26 @@ export class Mapbox extends MapboxCommon {
|
|
|
1333
1109
|
}
|
|
1334
1110
|
_stringToCameraMode(mode) {
|
|
1335
1111
|
switch (mode) {
|
|
1336
|
-
case
|
|
1112
|
+
case "NONE":
|
|
1337
1113
|
return 0;
|
|
1338
|
-
case
|
|
1339
|
-
|
|
1340
|
-
CLog(CLogTypes.info, '_stringToCameraMode(): NONE_COMPASS unsupported on iOS');
|
|
1341
|
-
}
|
|
1114
|
+
case "NONE_COMPASS":
|
|
1115
|
+
console.log("MapboxView::_stringToCameraMode(): NONE_COMPASS unsupported on iOS");
|
|
1342
1116
|
return 0;
|
|
1343
|
-
case
|
|
1344
|
-
|
|
1345
|
-
CLog(CLogTypes.info, '_stringToCameraMode(): NONE_GPS unsupported on iOS');
|
|
1346
|
-
}
|
|
1117
|
+
case "NONE_GPS":
|
|
1118
|
+
console.log("MapboxView::_stringToCameraMode(): NONE_GPS unsupported on iOS");
|
|
1347
1119
|
return 0;
|
|
1348
|
-
case
|
|
1120
|
+
case "TRACKING":
|
|
1349
1121
|
return 1;
|
|
1350
|
-
case
|
|
1122
|
+
case "TRACKING_COMPASS":
|
|
1351
1123
|
return 2;
|
|
1352
|
-
case
|
|
1124
|
+
case "TRACKING_GPS":
|
|
1353
1125
|
return 1;
|
|
1354
|
-
case
|
|
1126
|
+
case "TRACKING_GPS_NORTH":
|
|
1355
1127
|
return 3;
|
|
1128
|
+
default:
|
|
1129
|
+
console.log(`_stringToCameraMode: invalid cameraMode: ${mode}`);
|
|
1356
1130
|
}
|
|
1131
|
+
return 0;
|
|
1357
1132
|
}
|
|
1358
1133
|
_stringToRenderMode(mode) {
|
|
1359
1134
|
let renderMode;
|
|
@@ -1366,6 +1141,18 @@ export class Mapbox extends MapboxCommon {
|
|
|
1366
1141
|
return 'GPS';
|
|
1367
1142
|
}
|
|
1368
1143
|
}
|
|
1144
|
+
_convertCameraMode(mode) {
|
|
1145
|
+
switch (mode) {
|
|
1146
|
+
case 0:
|
|
1147
|
+
return "NONE";
|
|
1148
|
+
case 1:
|
|
1149
|
+
return "TRACKING";
|
|
1150
|
+
case 2:
|
|
1151
|
+
return "TRACKING_COMPASS";
|
|
1152
|
+
case 3:
|
|
1153
|
+
return "TRACKING_GPS_NORTH";
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1369
1156
|
showUserLocationMarker(options, nativeMap) {
|
|
1370
1157
|
return new Promise((resolve, reject) => {
|
|
1371
1158
|
try {
|
|
@@ -2059,6 +1846,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
2059
1846
|
const nsData = content.dataUsingEncoding(NSUTF8StringEncoding);
|
|
2060
1847
|
const geoJsonShape = MGLShape.shapeWithDataEncodingError(nsData, NSUTF8StringEncoding);
|
|
2061
1848
|
source.shape = geoJsonShape;
|
|
1849
|
+
resolve();
|
|
2062
1850
|
break;
|
|
2063
1851
|
default:
|
|
2064
1852
|
reject('Invalid source type: ' + options['type']);
|
|
@@ -2314,7 +2102,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
2314
2102
|
reject('The map is not currently showing the user location');
|
|
2315
2103
|
return;
|
|
2316
2104
|
}
|
|
2317
|
-
theMap.setUserTrackingModeAnimated(
|
|
2105
|
+
theMap.setUserTrackingModeAnimated(this._stringToCameraMode(options.cameraMode), options.animated !== false);
|
|
2318
2106
|
resolve();
|
|
2319
2107
|
}
|
|
2320
2108
|
catch (ex) {
|
|
@@ -2334,7 +2122,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
2334
2122
|
return;
|
|
2335
2123
|
}
|
|
2336
2124
|
const layer = theMap.style.layerWithIdentifier(name);
|
|
2337
|
-
resolve(new Layer(layer));
|
|
2125
|
+
resolve(layer ? new Layer(layer) : null);
|
|
2338
2126
|
}
|
|
2339
2127
|
catch (ex) {
|
|
2340
2128
|
if (Trace.isEnabled()) {
|
|
@@ -2384,6 +2172,13 @@ export class Mapbox extends MapboxCommon {
|
|
|
2384
2172
|
lng: coordinate.longitude
|
|
2385
2173
|
};
|
|
2386
2174
|
}
|
|
2175
|
+
getUserLocationCameraMode(nativeMap) {
|
|
2176
|
+
let theMap = nativeMap || this._mapboxViewInstance;
|
|
2177
|
+
if (!theMap) {
|
|
2178
|
+
return "NONE";
|
|
2179
|
+
}
|
|
2180
|
+
return this._convertCameraMode(theMap.userTrackingMode);
|
|
2181
|
+
}
|
|
2387
2182
|
}
|
|
2388
2183
|
const _addObserver = (eventName, callback) => NSNotificationCenter.defaultCenter.addObserverForNameObjectQueueUsingBlock(eventName, null, NSOperationQueue.mainQueue, callback);
|
|
2389
2184
|
function _downloadImage(marker) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativescript-community/ui-mapbox",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.19",
|
|
4
4
|
"description": "Interactive, thoroughly customizable maps powered by vector tiles and OpenGL.",
|
|
5
5
|
"main": "index",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@nativescript-community/perms": "^2.2.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "ee66b091255e4c94685c927f8ab652ad66b5a5be"
|
|
58
58
|
}
|
|
Binary file
|