@rnmapbox/maps 10.0.0-beta.65 → 10.0.0-beta.66
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/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt +1 -1
- package/index.d.ts +36 -166
- package/ios/RCTMGL-v10/RCTMGLLogging.swift +13 -0
- package/ios/RCTMGL-v10/RCTMGLMarkerView.swift +86 -55
- package/ios/RCTMGL-v10/RCTMGLOfflineModule.swift +138 -55
- package/javascript/components/BackgroundLayer.tsx +91 -0
- package/javascript/components/CircleLayer.tsx +97 -0
- package/javascript/components/FillExtrusionLayer.tsx +95 -0
- package/javascript/components/FillLayer.tsx +91 -0
- package/javascript/components/HeatmapLayer.tsx +96 -0
- package/javascript/components/NativeUserLocation.tsx +33 -0
- package/javascript/components/RasterLayer.tsx +88 -0
- package/javascript/components/SkyLayer.tsx +70 -0
- package/lib/commonjs/components/BackgroundLayer.js +6 -55
- package/lib/commonjs/components/BackgroundLayer.js.map +1 -1
- package/lib/commonjs/components/CircleLayer.js +8 -58
- package/lib/commonjs/components/CircleLayer.js.map +1 -1
- package/lib/commonjs/components/FillExtrusionLayer.js +3 -55
- package/lib/commonjs/components/FillExtrusionLayer.js.map +1 -1
- package/lib/commonjs/components/FillLayer.js +2 -55
- package/lib/commonjs/components/FillLayer.js.map +1 -1
- package/lib/commonjs/components/HeatmapLayer.js +3 -56
- package/lib/commonjs/components/HeatmapLayer.js.map +1 -1
- package/lib/commonjs/components/NativeUserLocation.js +6 -31
- package/lib/commonjs/components/NativeUserLocation.js.map +1 -1
- package/lib/commonjs/components/RasterLayer.js +1 -53
- package/lib/commonjs/components/RasterLayer.js.map +1 -1
- package/lib/commonjs/components/SkyLayer.js +2 -43
- package/lib/commonjs/components/SkyLayer.js.map +1 -1
- package/lib/module/components/BackgroundLayer.js +6 -55
- package/lib/module/components/BackgroundLayer.js.map +1 -1
- package/lib/module/components/CircleLayer.js +7 -57
- package/lib/module/components/CircleLayer.js.map +1 -1
- package/lib/module/components/FillExtrusionLayer.js +2 -54
- package/lib/module/components/FillExtrusionLayer.js.map +1 -1
- package/lib/module/components/FillLayer.js +1 -54
- package/lib/module/components/FillLayer.js.map +1 -1
- package/lib/module/components/HeatmapLayer.js +2 -55
- package/lib/module/components/HeatmapLayer.js.map +1 -1
- package/lib/module/components/NativeUserLocation.js +4 -30
- package/lib/module/components/NativeUserLocation.js.map +1 -1
- package/lib/module/components/RasterLayer.js +1 -53
- package/lib/module/components/RasterLayer.js.map +1 -1
- package/lib/module/components/SkyLayer.js +1 -42
- package/lib/module/components/SkyLayer.js.map +1 -1
- package/lib/typescript/components/BackgroundLayer.d.ts +62 -0
- package/lib/typescript/components/BackgroundLayer.d.ts.map +1 -0
- package/lib/typescript/components/CircleLayer.d.ts +66 -0
- package/lib/typescript/components/CircleLayer.d.ts.map +1 -0
- package/lib/typescript/components/FillExtrusionLayer.d.ts +65 -0
- package/lib/typescript/components/FillExtrusionLayer.d.ts.map +1 -0
- package/{javascript/components/FillLayer.js → lib/typescript/components/FillLayer.d.ts} +28 -57
- package/lib/typescript/components/FillLayer.d.ts.map +1 -0
- package/lib/typescript/components/HeatmapLayer.d.ts +66 -0
- package/lib/typescript/components/HeatmapLayer.d.ts.map +1 -0
- package/lib/typescript/components/NativeUserLocation.d.ts +22 -0
- package/lib/typescript/components/NativeUserLocation.d.ts.map +1 -0
- package/lib/typescript/components/RasterLayer.d.ts +62 -0
- package/lib/typescript/components/RasterLayer.d.ts.map +1 -0
- package/lib/typescript/components/SkyLayer.d.ts +52 -0
- package/lib/typescript/components/SkyLayer.d.ts.map +1 -0
- package/package.json +1 -1
- package/javascript/components/BackgroundLayer.js +0 -97
- package/javascript/components/CircleLayer.js +0 -101
- package/javascript/components/FillExtrusionLayer.js +0 -98
- package/javascript/components/HeatmapLayer.js +0 -99
- package/javascript/components/NativeUserLocation.js +0 -41
- package/javascript/components/RasterLayer.js +0 -95
- package/javascript/components/SkyLayer.js +0 -80
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt
CHANGED
|
@@ -93,7 +93,7 @@ class RCTMGLCamera(private val mContext: Context, private val mManager: RCTMGLCa
|
|
|
93
93
|
override fun onAnimationStart(animator: Animator) {}
|
|
94
94
|
override fun onAnimationEnd(animator: Animator) {
|
|
95
95
|
if (!hasSentFirstRegion) {
|
|
96
|
-
mMapView
|
|
96
|
+
mMapView?.sendRegionChangeEvent(false)
|
|
97
97
|
hasSentFirstRegion = true
|
|
98
98
|
}
|
|
99
99
|
}
|
package/index.d.ts
CHANGED
|
@@ -24,7 +24,14 @@ import {
|
|
|
24
24
|
|
|
25
25
|
import type {
|
|
26
26
|
SymbolLayerStyleProps,
|
|
27
|
+
CircleLayerStyleProps,
|
|
28
|
+
FillExtrusionLayerStyleProps,
|
|
29
|
+
SkyLayerStyleProps,
|
|
30
|
+
RasterLayerStyleProps,
|
|
31
|
+
HeatmapLayerStyleProps,
|
|
32
|
+
FillLayerStyleProps,
|
|
27
33
|
LineLayerStyleProps,
|
|
34
|
+
BackgroundLayerStyleProps,
|
|
28
35
|
} from './javascript/utils/MapboxStyles';
|
|
29
36
|
import { getAnnotationsLayerID as _getAnnotationsLayerID } from './javascript/utils/getAnnotationsLayerID';
|
|
30
37
|
import {
|
|
@@ -47,10 +54,16 @@ import {
|
|
|
47
54
|
SymbolLayer as _SymbolLayer,
|
|
48
55
|
Props as _SymbolLayerProps,
|
|
49
56
|
} from './javascript/components/SymbolLayer';
|
|
50
|
-
import {
|
|
51
|
-
LineLayer as _LineLayer,
|
|
57
|
+
import _LineLayer, {
|
|
52
58
|
Props as _LineLayerProps,
|
|
53
59
|
} from './javascript/components/LineLayer';
|
|
60
|
+
import { Props as _BackgroundLayerProps } from './javascript/components/BackgroundLayer';
|
|
61
|
+
import { Props as _CircleLayerProps } from './javascript/components/CircleLayer';
|
|
62
|
+
import { Props as _FillLayerProps } from './javascript/components/FillLayer';
|
|
63
|
+
import { Props as _FillExtrusionLayerProps } from './javascript/components/FillExtrusionLayer';
|
|
64
|
+
import { Props as _RasterLayerProps } from './javascript/components/RasterLayer';
|
|
65
|
+
import { Props as _HeatmapLayerProps } from './javascript/components/HeatmapLayer';
|
|
66
|
+
import { Props as _SkyLayerProps } from './javascript/components/SkyLayer';
|
|
54
67
|
import {
|
|
55
68
|
ShapeSource as _ShapeSource,
|
|
56
69
|
Props as _ShapeSourceProps,
|
|
@@ -111,17 +124,6 @@ type Visibility = 'visible' | 'none';
|
|
|
111
124
|
type Alignment = 'map' | 'viewport';
|
|
112
125
|
type AutoAlignment = Alignment | 'auto';
|
|
113
126
|
|
|
114
|
-
type NamedStyles<T> = {
|
|
115
|
-
[P in keyof T]:
|
|
116
|
-
| SymbolLayerStyleProps
|
|
117
|
-
| RasterLayerStyle
|
|
118
|
-
| LineLayerStyleProps
|
|
119
|
-
| FillLayerStyle
|
|
120
|
-
| FillExtrusionLayerStyle
|
|
121
|
-
| CircleLayerStyle
|
|
122
|
-
| BackgroundLayerStyle;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
127
|
export type OnPressEvent = {
|
|
126
128
|
features: Array<GeoJSON.Feature>;
|
|
127
129
|
coordinates: {
|
|
@@ -281,13 +283,13 @@ declare namespace MapboxGL {
|
|
|
281
283
|
class ImageSource extends Component<ImageSourceProps> {}
|
|
282
284
|
|
|
283
285
|
// layers
|
|
284
|
-
class FillLayer extends Component<
|
|
285
|
-
class FillExtrusionLayer extends Component<
|
|
286
|
+
class FillLayer extends Component<_FillLayerProps> {}
|
|
287
|
+
class FillExtrusionLayer extends Component<_FillExtrusionLayerProps> {}
|
|
286
288
|
class LineLayer extends Component<_LineLayerProps> {}
|
|
287
|
-
class CircleLayer extends Component<
|
|
289
|
+
class CircleLayer extends Component<_CircleLayerProps> {}
|
|
288
290
|
class SymbolLayer extends Component<_SymbolLayerProps> {}
|
|
289
|
-
class RasterLayer extends Component<
|
|
290
|
-
class BackgroundLayer extends Component<
|
|
291
|
+
class RasterLayer extends Component<_RasterLayerProps> {}
|
|
292
|
+
class BackgroundLayer extends Component<_BackgroundLayerProps> {}
|
|
291
293
|
}
|
|
292
294
|
|
|
293
295
|
/**
|
|
@@ -370,26 +372,6 @@ declare namespace MapboxGL {
|
|
|
370
372
|
|
|
371
373
|
class Light extends Component<LightProps> {}
|
|
372
374
|
|
|
373
|
-
class StyleSheet extends Component {
|
|
374
|
-
static create<T extends NamedStyles<T> | NamedStyles<any>>(styles: T): T;
|
|
375
|
-
camera(
|
|
376
|
-
stops: { [key: number]: string },
|
|
377
|
-
interpolationMode?: InterpolationMode,
|
|
378
|
-
): void;
|
|
379
|
-
source(
|
|
380
|
-
stops: { [key: number]: string },
|
|
381
|
-
attributeName: string,
|
|
382
|
-
interpolationMode?: InterpolationMode,
|
|
383
|
-
): void;
|
|
384
|
-
composite(
|
|
385
|
-
stops: { [key: number]: string },
|
|
386
|
-
attributeName: string,
|
|
387
|
-
interpolationMode?: InterpolationMode,
|
|
388
|
-
): void;
|
|
389
|
-
|
|
390
|
-
identity(attributeName: string): number;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
375
|
class Callout extends Component<CalloutProps> {}
|
|
394
376
|
type Style = React.FC<StyleProps>;
|
|
395
377
|
|
|
@@ -403,16 +385,16 @@ declare namespace MapboxGL {
|
|
|
403
385
|
/**
|
|
404
386
|
* Layers
|
|
405
387
|
*/
|
|
406
|
-
class BackgroundLayer extends Component<
|
|
407
|
-
class CircleLayer extends Component<
|
|
408
|
-
class FillExtrusionLayer extends Component<
|
|
409
|
-
class FillLayer extends Component<
|
|
410
|
-
class LineLayer extends Component<
|
|
411
|
-
class RasterLayer extends Component<
|
|
412
|
-
class HeatmapLayer extends Component<
|
|
388
|
+
class BackgroundLayer extends Component<_BackgroundLayerProps> {}
|
|
389
|
+
class CircleLayer extends Component<_CircleLayerProps> {}
|
|
390
|
+
class FillExtrusionLayer extends Component<_FillExtrusionLayerProps> {}
|
|
391
|
+
class FillLayer extends Component<_FillLayerProps> {}
|
|
392
|
+
class LineLayer extends Component<_LineLayerProps> {}
|
|
393
|
+
class RasterLayer extends Component<_RasterLayerProps> {}
|
|
394
|
+
class HeatmapLayer extends Component<_HeatmapLayerProps> {}
|
|
413
395
|
class Images extends Component<ImagesProps> {}
|
|
414
396
|
class ImageSource extends Component<ImageSourceProps> {}
|
|
415
|
-
class SkyLayer extends Component<
|
|
397
|
+
class SkyLayer extends Component<_SkyLayerProps> {}
|
|
416
398
|
|
|
417
399
|
class LocationManager extends Component {
|
|
418
400
|
start(displacement?: number): void;
|
|
@@ -639,121 +621,19 @@ export interface Transition {
|
|
|
639
621
|
delay: number;
|
|
640
622
|
}
|
|
641
623
|
|
|
642
|
-
export
|
|
643
|
-
visibility?: Visibility | Expression;
|
|
644
|
-
backgroundColor?: string | Expression;
|
|
645
|
-
backgroundColorTransition?: Transition | Expression;
|
|
646
|
-
backgroundPattern?: string | Expression;
|
|
647
|
-
backgroundPatternTransition?: Transition | Expression;
|
|
648
|
-
backgroundOpacity?: number | Expression;
|
|
649
|
-
backgroundOpacityTransition?: Transition | Expression;
|
|
650
|
-
}
|
|
624
|
+
export type BackgroundLayerStyle = BackgroundLayerStyleProps;
|
|
651
625
|
|
|
652
|
-
export
|
|
653
|
-
visibility?: Visibility | Expression;
|
|
654
|
-
circleRadius?: number | Expression;
|
|
655
|
-
circleRadiusTransition?: Transition | Expression;
|
|
656
|
-
circleColor?: string | Expression;
|
|
657
|
-
circleColorTransition?: Transition | Expression;
|
|
658
|
-
circleBlur?: number | Expression;
|
|
659
|
-
circleBlurTransition?: Transition | Expression;
|
|
660
|
-
circleOpacity?: number | Expression;
|
|
661
|
-
circleOpacityTransition?: Transition | Expression;
|
|
662
|
-
circleTranslate?: Array<number> | Expression;
|
|
663
|
-
circleTranslateTransition?: Transition | Expression;
|
|
664
|
-
circleTranslateAnchor?: Alignment | Expression;
|
|
665
|
-
circlePitchScale?: Alignment | Expression;
|
|
666
|
-
circlePitchAlignment?: Alignment | Expression;
|
|
667
|
-
circleStrokeWidth?: number | Expression;
|
|
668
|
-
circleStrokeWidthTransition?: Transition | Expression;
|
|
669
|
-
circleStrokeColor?: string | Expression;
|
|
670
|
-
circleStrokeColorTransition?: Transition | Expression;
|
|
671
|
-
circleStrokeOpacity?: number | Expression;
|
|
672
|
-
circleStrokeOpacityTransition?: Transition | Expression;
|
|
673
|
-
}
|
|
626
|
+
export type CircleLayerStyle = CircleLayerStyleProps;
|
|
674
627
|
|
|
675
|
-
export
|
|
676
|
-
visibility?: Visibility | Expression;
|
|
677
|
-
fillExtrusionOpacity?: number | Expression;
|
|
678
|
-
fillExtrusionOpacityTransition?: Transition | Expression;
|
|
679
|
-
fillExtrusionColor?: string | Expression;
|
|
680
|
-
fillExtrusionColorTransition?: Transition | Expression;
|
|
681
|
-
fillExtrusionTranslate?: Array<number> | Expression;
|
|
682
|
-
fillExtrusionTranslateTransition?: Transition | Expression;
|
|
683
|
-
fillExtrusionTranslateAnchor?: Alignment | Expression;
|
|
684
|
-
fillExtrusionPattern?: string | Expression;
|
|
685
|
-
fillExtrusionPatternTransition?: Transition | Expression;
|
|
686
|
-
fillExtrusionHeight?: number | Expression;
|
|
687
|
-
fillExtrusionHeightTransition?: Transition | Expression;
|
|
688
|
-
fillExtrusionBase?: number | Expression;
|
|
689
|
-
fillExtrusionBaseTransition?: Transition | Expression;
|
|
690
|
-
}
|
|
628
|
+
export type FillExtrusionLayerStyle = FillExtrusionLayerStyleProps;
|
|
691
629
|
|
|
692
|
-
export
|
|
693
|
-
visibility?: Visibility | Expression;
|
|
694
|
-
fillAntialias?: boolean | Expression;
|
|
695
|
-
fillOpacity?: number | Expression;
|
|
696
|
-
fillExtrusionOpacityTransition?: Transition | Expression;
|
|
697
|
-
fillColor?: string | Expression;
|
|
698
|
-
fillColorTransition?: Transition | Expression;
|
|
699
|
-
fillOutlineColor?: string | Expression;
|
|
700
|
-
fillOutlineColorTransition?: Transition | Expression;
|
|
701
|
-
fillTranslate?: Array<number> | Expression;
|
|
702
|
-
fillTranslateTransition?: Transition | Expression;
|
|
703
|
-
fillTranslateAnchor?: Alignment | Expression;
|
|
704
|
-
fillPattern?: string | Expression;
|
|
705
|
-
fillPatternTransition?: Transition | Expression;
|
|
706
|
-
}
|
|
630
|
+
export type FillLayerStyle = FillLayerStyleProps;
|
|
707
631
|
|
|
708
|
-
export
|
|
709
|
-
skyType: string | Expression;
|
|
710
|
-
skyAtmosphereSun?: Array<number> | Expression;
|
|
711
|
-
skyAtmosphereSunIntensity: number | Expression;
|
|
712
|
-
}
|
|
632
|
+
export type SkyLayerStyle = SkyLayerStyleProps;
|
|
713
633
|
|
|
714
|
-
export
|
|
715
|
-
lineCap?: 'butt' | 'round' | 'square' | Expression;
|
|
716
|
-
lineJoin?: 'bevel' | 'round' | 'miter' | Expression;
|
|
717
|
-
lineMiterLimit?: number | Expression;
|
|
718
|
-
lineRoundLimit?: number | Expression;
|
|
719
|
-
visibility?: Visibility | Expression;
|
|
720
|
-
lineOpacity?: number | Expression;
|
|
721
|
-
lineOpacityTransition?: Transition | Expression;
|
|
722
|
-
lineColor?: string | Expression;
|
|
723
|
-
lineColorTransition?: Transition | Expression;
|
|
724
|
-
lineTranslate?: Array<number> | Expression;
|
|
725
|
-
lineTranslateTransition?: Transition | Expression;
|
|
726
|
-
lineTranslateAnchor?: Alignment | Expression;
|
|
727
|
-
lineWidth?: number | Expression;
|
|
728
|
-
lineWidthTransition?: Transition | Expression;
|
|
729
|
-
lineGapWidth?: number | Expression;
|
|
730
|
-
lineGapWidthTransition?: Transition | Expression;
|
|
731
|
-
lineOffset?: number | Expression;
|
|
732
|
-
lineOffsetTransition?: Transition | Expression;
|
|
733
|
-
lineBlur?: number | Expression;
|
|
734
|
-
lineBlurTransition?: Transition | Expression;
|
|
735
|
-
lineDasharray?: Array<number> | Expression;
|
|
736
|
-
lineDasharrayTransition?: Transition | Expression;
|
|
737
|
-
linePattern?: string | Expression;
|
|
738
|
-
linePatternTransition?: Transition | Expression;
|
|
739
|
-
}
|
|
634
|
+
export type LineLayerStyle = LineLayerStyleProps;
|
|
740
635
|
|
|
741
|
-
export
|
|
742
|
-
visibility?: Visibility | Expression;
|
|
743
|
-
rasterOpacity?: number | Expression;
|
|
744
|
-
rasterOpacityTransition?: Transition | Expression;
|
|
745
|
-
rasterHueRotate?: Expression;
|
|
746
|
-
rasterHueRotateTransition?: Transition | Expression;
|
|
747
|
-
rasterBrightnessMin?: number | Expression;
|
|
748
|
-
rasterBrightnessMinTransition?: Transition | Expression;
|
|
749
|
-
rasterBrightnessMax?: number | Expression;
|
|
750
|
-
rasterBrightnessMaxTransition?: Transition | Expression;
|
|
751
|
-
rasterSaturation?: number | Expression;
|
|
752
|
-
rasterSaturationTransition?: Transition | Expression;
|
|
753
|
-
rasterContrast?: number | Expression;
|
|
754
|
-
rasterContrastTransition?: Transition | Expression;
|
|
755
|
-
rasterFadeDuration?: number | Expression;
|
|
756
|
-
}
|
|
636
|
+
export type RasterLayerStyle = RasterLayerStyleProps;
|
|
757
637
|
|
|
758
638
|
export type TextVariableAnchorValues =
|
|
759
639
|
| 'center'
|
|
@@ -769,17 +649,7 @@ export type TextVariableAnchorValues =
|
|
|
769
649
|
export type SymbolLayerStyle = SymbolLayerStyleProps;
|
|
770
650
|
export type LineLayerStyle = LineLayerStyleProps;
|
|
771
651
|
|
|
772
|
-
export
|
|
773
|
-
visibility?: Visibility | Expression;
|
|
774
|
-
heatmapRadius?: number | Expression;
|
|
775
|
-
heatmapRadiusTransition?: Transition | Expression;
|
|
776
|
-
heatmapWeight?: number | Expression;
|
|
777
|
-
heatmapIntensity?: number | Expression;
|
|
778
|
-
heatmapIntensityTransition?: Transition | Expression;
|
|
779
|
-
heatmapColor?: string | Expression;
|
|
780
|
-
heatmapOpacity?: number | Expression;
|
|
781
|
-
heatmapOpacityTransition?: Transition | Expression;
|
|
782
|
-
}
|
|
652
|
+
export type HeatmapLayerStyle = HeatmapLayerStyleProps;
|
|
783
653
|
|
|
784
654
|
export interface Point {
|
|
785
655
|
x: number;
|
|
@@ -81,6 +81,19 @@ func errorMessage(_ error: Error) -> String {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/// log message if optional returned by `fn` is nil
|
|
85
|
+
func logged<T>(_ msg: String, info: (() -> String)? = nil, level: Logger.LogLevel = .error, rejecter: RCTPromiseRejectBlock? = nil, fn: () -> T?) ->T? {
|
|
86
|
+
let ret = fn()
|
|
87
|
+
if ret == nil {
|
|
88
|
+
Logger.log(level:level, message: "\(msg) \(info?() ?? "")")
|
|
89
|
+
rejecter?(msg, "\(info?() ?? "")", NSError(domain:"is null", code: 0))
|
|
90
|
+
return nil
|
|
91
|
+
} else {
|
|
92
|
+
return ret
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// log message if `fn` throws and return nil
|
|
84
97
|
func logged<T>(_ msg: String, info: (() -> String)? = nil, level: Logger.LogLevel = .error, rejecter: RCTPromiseRejectBlock? = nil, fn : () throws -> T) -> T? {
|
|
85
98
|
do {
|
|
86
99
|
return try fn()
|
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import MapboxMaps
|
|
2
2
|
import UIKit
|
|
3
3
|
|
|
4
|
+
/// dummy parent of RCTMGLMarkerView, so react-native changes visibility on RCTMGLMarkerView,
|
|
5
|
+
/// and Mapbox changes visibility on RCTMGLMarkerViewParentViewAnnotation
|
|
6
|
+
class RCTMGLMarkerViewParentViewAnnotation : UIView {
|
|
7
|
+
required init(marker: RCTMGLMarkerView) {
|
|
8
|
+
super.init(frame: marker.bounds)
|
|
9
|
+
insertSubview(marker, at: 0)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
required init?(coder: NSCoder) {
|
|
13
|
+
fatalError("not implented")
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
func remove(marker: RCTMGLMarkerView) {
|
|
17
|
+
marker.removeFromSuperview()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
func updateSize(_ size: CGSize, oldOffset: CGVector, newOffset: CGVector) {
|
|
21
|
+
let actSize = self.frame.size
|
|
22
|
+
if actSize.width != size.width || actSize.height != size.height {
|
|
23
|
+
let dx = ((size.width/2.0) - newOffset.dx) - ((actSize.width/2.0) - oldOffset.dx)
|
|
24
|
+
let dy = ((size.height/2.0) + newOffset.dy) - ((actSize.height/2.0) + oldOffset.dy)
|
|
25
|
+
print(" => size=\(size) actSize=\(actSize) newOffset=\(newOffset) oldOffset=\(oldOffset) dx=\(dx) dy=\(dy)")
|
|
26
|
+
var frame = self.frame
|
|
27
|
+
frame = frame.offsetBy(dx: -dx, dy: -dy)
|
|
28
|
+
frame.size = size
|
|
29
|
+
self.frame = frame
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
4
34
|
class RCTMGLMarkerView: UIView, RCTMGLMapComponent {
|
|
5
35
|
// MARK: - Instance variables
|
|
6
36
|
|
|
@@ -8,6 +38,7 @@ class RCTMGLMarkerView: UIView, RCTMGLMapComponent {
|
|
|
8
38
|
let id: String = "marker-\(UUID().uuidString)"
|
|
9
39
|
|
|
10
40
|
weak var map: RCTMGLMapView?
|
|
41
|
+
weak var _annotationView: RCTMGLMarkerViewParentViewAnnotation?
|
|
11
42
|
|
|
12
43
|
var didAddToMap = false
|
|
13
44
|
|
|
@@ -31,13 +62,7 @@ class RCTMGLMarkerView: UIView, RCTMGLMapComponent {
|
|
|
31
62
|
|
|
32
63
|
@objc var isSelected: Bool = false {
|
|
33
64
|
didSet {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if hasBecomeSelected {
|
|
37
|
-
setSelected()
|
|
38
|
-
} else {
|
|
39
|
-
update()
|
|
40
|
-
}
|
|
65
|
+
update()
|
|
41
66
|
}
|
|
42
67
|
}
|
|
43
68
|
|
|
@@ -89,36 +114,33 @@ class RCTMGLMarkerView: UIView, RCTMGLMapComponent {
|
|
|
89
114
|
|
|
90
115
|
// MARK: - React methods
|
|
91
116
|
|
|
117
|
+
override var isHidden: Bool {
|
|
118
|
+
get {
|
|
119
|
+
return super.isHidden
|
|
120
|
+
}
|
|
121
|
+
set {
|
|
122
|
+
super.isHidden = newValue
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
92
126
|
override func reactSetFrame(_ frame: CGRect) {
|
|
93
127
|
let prev = self.frame
|
|
94
128
|
var next = frame
|
|
95
129
|
|
|
96
130
|
let frameDidChange = !next.equalTo(prev)
|
|
97
|
-
if
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
next
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
width: next.width,
|
|
105
|
-
height: next.height
|
|
106
|
-
)
|
|
107
|
-
} else {
|
|
108
|
-
// Calculate the next position to temporarily place the view before the annotation manager
|
|
109
|
-
// sets it to the correct point on the map.
|
|
110
|
-
let dx = (next.width - prev.width) / 2
|
|
111
|
-
let dy = (next.height - prev.height) / 2
|
|
112
|
-
next = CGRect(
|
|
113
|
-
x: prev.minX - dx,
|
|
114
|
-
y: prev.minY - dy,
|
|
115
|
-
width: next.width,
|
|
116
|
-
height: next.height
|
|
117
|
-
)
|
|
118
|
-
}
|
|
131
|
+
if frameDidChange {
|
|
132
|
+
next = CGRect(
|
|
133
|
+
x: 0,
|
|
134
|
+
y: 0,
|
|
135
|
+
width: next.width,
|
|
136
|
+
height: next.height
|
|
137
|
+
)
|
|
119
138
|
}
|
|
120
|
-
|
|
139
|
+
|
|
121
140
|
super.reactSetFrame(next)
|
|
141
|
+
if frameDidChange {
|
|
142
|
+
annotationView.updateSize(next.size, oldOffset:calcOffset(size: prev.size), newOffset: calcOffset(size: next.size))
|
|
143
|
+
}
|
|
122
144
|
addOrUpdate()
|
|
123
145
|
}
|
|
124
146
|
|
|
@@ -156,7 +178,7 @@ class RCTMGLMarkerView: UIView, RCTMGLMapComponent {
|
|
|
156
178
|
|
|
157
179
|
do {
|
|
158
180
|
let options = getOptions()
|
|
159
|
-
try annotationManager.add(
|
|
181
|
+
try annotationManager.add(annotationView, id: id, options: options)
|
|
160
182
|
didAddToMap = true
|
|
161
183
|
} catch {
|
|
162
184
|
Logger.log(level: .error, message: "[MarkerView] Error adding annotation", error: error)
|
|
@@ -174,27 +196,16 @@ class RCTMGLMarkerView: UIView, RCTMGLMapComponent {
|
|
|
174
196
|
|
|
175
197
|
do {
|
|
176
198
|
let options = getOptions()
|
|
177
|
-
try annotationManager.update(
|
|
199
|
+
try annotationManager.update(annotationView, options: options)
|
|
178
200
|
} catch {
|
|
179
201
|
Logger.log(level: .error, message: "[MarkerView] Error updating annotation", error: error)
|
|
180
202
|
}
|
|
181
203
|
}
|
|
182
204
|
|
|
183
|
-
/// There is a Mapbox bug where `selected` does not cause the marker to move to the front, so we can't simply update the component.
|
|
184
|
-
/// This forces that effect. See https://github.com/mapbox/mapbox-maps-ios/issues/1599.
|
|
185
|
-
private func setSelected() {
|
|
186
|
-
if let options = annotationManager?.options(for: self) {
|
|
187
|
-
do {
|
|
188
|
-
annotationManager?.remove(self)
|
|
189
|
-
try annotationManager?.add(self, id: id, options: options)
|
|
190
|
-
} catch {
|
|
191
|
-
Logger.log(level: .error, message: "[MarkerView] Error selecting annotation", error: error)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
205
|
private func remove() {
|
|
197
|
-
annotationManager?.remove(
|
|
206
|
+
annotationManager?.remove(annotationView)
|
|
207
|
+
annotationView.remove(marker: self)
|
|
208
|
+
self._annotationView = nil
|
|
198
209
|
didAddToMap = false
|
|
199
210
|
}
|
|
200
211
|
|
|
@@ -206,29 +217,49 @@ class RCTMGLMarkerView: UIView, RCTMGLMapComponent {
|
|
|
206
217
|
geometry = Geometry.point(point)
|
|
207
218
|
}
|
|
208
219
|
|
|
209
|
-
let
|
|
220
|
+
let size = self.bounds.size
|
|
221
|
+
let offset = calcOffset(size: size)
|
|
210
222
|
|
|
211
223
|
let options = ViewAnnotationOptions(
|
|
212
224
|
geometry: geometry,
|
|
213
|
-
width:
|
|
214
|
-
height:
|
|
225
|
+
width: size.width,
|
|
226
|
+
height: size.height,
|
|
215
227
|
allowOverlap: allowOverlap,
|
|
216
228
|
offsetX: offset.dx,
|
|
217
|
-
offsetY: offset.dy
|
|
229
|
+
offsetY: offset.dy,
|
|
230
|
+
selected: isSelected
|
|
218
231
|
)
|
|
219
232
|
return options
|
|
220
233
|
}
|
|
221
234
|
|
|
222
|
-
private func
|
|
235
|
+
private func calcOffset(size: CGSize) -> CGVector {
|
|
223
236
|
guard let anchor = anchor, let anchorX = anchor["x"]?.CGFloat, let anchorY = anchor["y"]?.CGFloat else {
|
|
224
237
|
return .zero
|
|
225
238
|
}
|
|
226
239
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
let x = (anchorX * 2 - 1) * (self.bounds.width / 2) * -1
|
|
230
|
-
let y = (anchorY * 2 - 1) * (self.bounds.height / 2)
|
|
240
|
+
let x = (anchorX * 2 - 1) * (size.width / 2) * -1
|
|
241
|
+
let y = (anchorY * 2 - 1) * (size.height / 2)
|
|
231
242
|
|
|
232
243
|
return CGVector(dx: x, dy: y)
|
|
233
244
|
}
|
|
245
|
+
|
|
246
|
+
var annotationView : RCTMGLMarkerViewParentViewAnnotation {
|
|
247
|
+
if let result = _annotationView {
|
|
248
|
+
return result
|
|
249
|
+
}
|
|
250
|
+
let result = RCTMGLMarkerViewParentViewAnnotation(marker: self)
|
|
251
|
+
_annotationView = result
|
|
252
|
+
return result
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
@objc override func didMoveToSuperview() {
|
|
256
|
+
// React tends to add back us to our original superview,
|
|
257
|
+
// https://github.com/facebook/react-native/blob/11ece22fc6955d169def9ef9f2809c24bc457ba8/React/Views/UIView%2BReact.m#L172-L177
|
|
258
|
+
// fix that if we see that
|
|
259
|
+
if let expectedParent = _annotationView {
|
|
260
|
+
if superview != nil && superview != expectedParent {
|
|
261
|
+
expectedParent.addSubview(self)
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
234
265
|
}
|