@rnmapbox/maps 10.0.0-beta.45 → 10.0.0-beta.47
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/AbstractMapFeature.kt +23 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerView.kt +3 -4
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.kt +2 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt +19 -10
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCameraManager.kt +16 -25
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImages.kt +2 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/RCTMGLNativeUserLocation.kt +2 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +217 -69
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.kt +22 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/atmosphere/RCTMGLAtmosphere.kt +2 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +2 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSource.kt +4 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTSource.kt +2 -3
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/terrain/RCTMGLTerrain.kt +2 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/CustomHttpHeaders.kt +38 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLModule.kt +12 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/LatLngBounds.kt +35 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/extensions/CoordinateBounds.kt +23 -0
- package/docs/docs.json +2 -2
- package/ios/RCTMGL-v10/RCTMGLCamera.swift +37 -2
- package/ios/RCTMGL-v10/RCTMGLCameraManager.m +1 -0
- package/ios/RCTMGL-v10/RCTMGLMapView.swift +70 -9
- package/ios/RCTMGL-v10/RCTMGLShapeSource.swift +29 -23
- package/ios/RCTMGL-v10/RCTMGLShapeSourceManager.m +3 -3
- package/ios/RCTMGL-v10/RCTMGLShapeSourceManager.swift +3 -3
- package/javascript/components/MarkerView.tsx +15 -1
- package/javascript/components/ShapeSource.tsx +3 -3
- package/package.json +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/LatLngBounds.java +0 -42
|
@@ -5,6 +5,27 @@ import com.facebook.react.views.view.ReactViewGroup
|
|
|
5
5
|
import com.mapbox.rctmgl.components.mapview.RCTMGLMapView
|
|
6
6
|
|
|
7
7
|
abstract class AbstractMapFeature(context: Context?) : ReactViewGroup(context) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
protected var mMapView: RCTMGLMapView? = null;
|
|
9
|
+
private var mWithMapViewCallbacks: Array<((RCTMGLMapView) -> Unit)>? = null;
|
|
10
|
+
|
|
11
|
+
open fun addToMap(mapView: RCTMGLMapView) {
|
|
12
|
+
mMapView = mapView;
|
|
13
|
+
mWithMapViewCallbacks?.forEach { it(mapView) }
|
|
14
|
+
mWithMapViewCallbacks = null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
open fun removeFromMap(mapView: RCTMGLMapView) {
|
|
18
|
+
mMapView = null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
internal fun withMapView(callback: (mapView: RCTMGLMapView) -> Unit) {
|
|
22
|
+
val mapView = mMapView;
|
|
23
|
+
if (mapView == null) {
|
|
24
|
+
val callbacks = mWithMapViewCallbacks ?: arrayOf();
|
|
25
|
+
callbacks.plus(callback)
|
|
26
|
+
mWithMapViewCallbacks = callbacks
|
|
27
|
+
} else {
|
|
28
|
+
callback(mapView)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
10
31
|
}
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerView.kt
CHANGED
|
@@ -23,8 +23,6 @@ class RCTMGLMarkerView(context: Context?, private val mManager: RCTMGLMarkerView
|
|
|
23
23
|
View.OnLayoutChangeListener
|
|
24
24
|
{
|
|
25
25
|
// region Instance variables
|
|
26
|
-
|
|
27
|
-
private var mMapView: RCTMGLMapView? = null
|
|
28
26
|
private var mView: View? = null
|
|
29
27
|
private var didAddToMap = false
|
|
30
28
|
|
|
@@ -72,14 +70,15 @@ class RCTMGLMarkerView(context: Context?, private val mManager: RCTMGLMarkerView
|
|
|
72
70
|
|
|
73
71
|
// endregion
|
|
74
72
|
|
|
75
|
-
// region
|
|
73
|
+
// region AbstractMapFeature methods
|
|
76
74
|
|
|
77
75
|
override fun addToMap(mapView: RCTMGLMapView) {
|
|
78
|
-
|
|
76
|
+
super.addToMap(mapView)
|
|
79
77
|
add()
|
|
80
78
|
}
|
|
81
79
|
|
|
82
80
|
override fun removeFromMap(mapView: RCTMGLMapView) {
|
|
81
|
+
super.removeFromMap(mapView)
|
|
83
82
|
remove(mapView)
|
|
84
83
|
}
|
|
85
84
|
|
|
@@ -28,7 +28,6 @@ class RCTMGLPointAnnotation(private val mContext: Context, private val mManager:
|
|
|
28
28
|
var marker: PointAnnotation? = null
|
|
29
29
|
private set
|
|
30
30
|
private var mMap: MapboxMap? = null
|
|
31
|
-
private var mMapView: RCTMGLMapView? = null
|
|
32
31
|
private val mHasChildren = false
|
|
33
32
|
private var mCoordinate: Point? = null
|
|
34
33
|
var iD: String? = null
|
|
@@ -74,7 +73,7 @@ class RCTMGLPointAnnotation(private val mContext: Context, private val mManager:
|
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
override fun addToMap(mapView: RCTMGLMapView) {
|
|
77
|
-
|
|
76
|
+
super.addToMap(mapView)
|
|
78
77
|
mMap = mapView.getMapboxMap()
|
|
79
78
|
makeMarker()
|
|
80
79
|
if (mChildView != null) {
|
|
@@ -103,6 +102,7 @@ class RCTMGLPointAnnotation(private val mContext: Context, private val mManager:
|
|
|
103
102
|
if (calloutView != null) {
|
|
104
103
|
map.offscreenAnnotationViewContainer?.removeView(calloutView)
|
|
105
104
|
}
|
|
105
|
+
super.removeFromMap(mapView)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
override fun onLayoutChange(v: View, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int,
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt
CHANGED
|
@@ -45,11 +45,12 @@ import com.mapbox.rctmgl.modules.RCTMGLLogging
|
|
|
45
45
|
import com.mapbox.rctmgl.utils.LatLng
|
|
46
46
|
import com.mapbox.rctmgl.utils.Logger
|
|
47
47
|
|
|
48
|
+
|
|
49
|
+
|
|
48
50
|
class RCTMGLCamera(private val mContext: Context, private val mManager: RCTMGLCameraManager) :
|
|
49
51
|
AbstractMapFeature(
|
|
50
52
|
mContext
|
|
51
53
|
) {
|
|
52
|
-
private var mMapView: RCTMGLMapView? = null
|
|
53
54
|
private var hasSentFirstRegion = false
|
|
54
55
|
private var mDefaultStop: CameraStop? = null
|
|
55
56
|
private var mCameraStop: CameraStop? = null
|
|
@@ -117,7 +118,7 @@ class RCTMGLCamera(private val mContext: Context, private val mManager: RCTMGLCa
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
override fun addToMap(mapView: RCTMGLMapView) {
|
|
120
|
-
|
|
121
|
+
super.addToMap(mapView)
|
|
121
122
|
setInitialCamera()
|
|
122
123
|
updateMaxMinZoomLevel()
|
|
123
124
|
updateMaxBounds()
|
|
@@ -128,7 +129,9 @@ class RCTMGLCamera(private val mContext: Context, private val mManager: RCTMGLCa
|
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
|
|
131
|
-
override fun removeFromMap(mapView: RCTMGLMapView) {
|
|
132
|
+
override fun removeFromMap(mapView: RCTMGLMapView) {
|
|
133
|
+
super.removeFromMap(mapView)
|
|
134
|
+
}
|
|
132
135
|
fun setStop(stop: CameraStop) {
|
|
133
136
|
mCameraStop = stop
|
|
134
137
|
mCameraStop!!.setCallback(mCameraCallback)
|
|
@@ -161,14 +164,20 @@ class RCTMGLCamera(private val mContext: Context, private val mManager: RCTMGLCa
|
|
|
161
164
|
updateMaxBounds()
|
|
162
165
|
}
|
|
163
166
|
|
|
167
|
+
|
|
164
168
|
private fun updateMaxBounds() {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
withMapView { mapView ->
|
|
170
|
+
val map = mapView.getMapboxMap()
|
|
171
|
+
val maxBounds = mMaxBounds
|
|
172
|
+
if (maxBounds != null) {
|
|
173
|
+
map.setBounds(CameraBoundsOptions.Builder().bounds(
|
|
174
|
+
maxBounds.toBounds()
|
|
175
|
+
).build())
|
|
176
|
+
} else {
|
|
177
|
+
map.setBounds(CameraBoundsOptions.Builder().build())
|
|
178
|
+
}
|
|
170
179
|
|
|
171
|
-
|
|
180
|
+
}
|
|
172
181
|
}
|
|
173
182
|
|
|
174
183
|
private fun updateMaxMinZoomLevel() {
|
|
@@ -319,7 +328,7 @@ class RCTMGLCamera(private val mContext: Context, private val mManager: RCTMGLCa
|
|
|
319
328
|
});
|
|
320
329
|
*/
|
|
321
330
|
} else {
|
|
322
|
-
mLocationComponentManager!!.setCameraMode(CameraMode.NONE)
|
|
331
|
+
mLocationComponentManager!!.setCameraMode(com.mapbox.rctmgl.components.location.CameraMode.NONE)
|
|
323
332
|
}
|
|
324
333
|
}
|
|
325
334
|
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCameraManager.kt
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
package com.mapbox.rctmgl.components.camera
|
|
2
2
|
|
|
3
|
-
import com.mapbox.rctmgl.components.camera.CameraStop.Companion.fromReadableMap
|
|
4
|
-
import com.mapbox.maps.MapboxMap
|
|
5
|
-
import com.mapbox.maps.CameraOptions
|
|
6
|
-
import com.mapbox.maps.plugin.animation.CameraAnimationsPlugin
|
|
7
|
-
import android.view.animation.LinearInterpolator
|
|
8
|
-
import android.view.animation.AccelerateDecelerateInterpolator
|
|
9
|
-
import com.mapbox.rctmgl.components.camera.CameraStop
|
|
10
|
-
import com.mapbox.rctmgl.components.camera.CameraUpdateQueue.OnCompleteAllListener
|
|
11
|
-
import com.mapbox.rctmgl.components.mapview.RCTMGLMapView
|
|
12
|
-
import com.mapbox.rctmgl.components.camera.CameraUpdateItem
|
|
13
3
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
14
|
-
import com.
|
|
15
|
-
import com.mapbox.rctmgl.components.camera.RCTMGLCamera
|
|
16
|
-
import com.mapbox.rctmgl.components.camera.RCTMGLCameraManager
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
17
5
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
18
6
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
19
|
-
import com.
|
|
20
|
-
import
|
|
21
|
-
import
|
|
7
|
+
import com.mapbox.geojson.FeatureCollection
|
|
8
|
+
import com.mapbox.rctmgl.components.AbstractEventEmitter
|
|
9
|
+
import com.mapbox.rctmgl.components.camera.CameraStop.Companion.fromReadableMap
|
|
10
|
+
import com.mapbox.rctmgl.utils.GeoJSONUtils.toLatLngBounds
|
|
11
|
+
|
|
22
12
|
|
|
23
13
|
//import com.mapbox.rctmgl.utils.GeoJSONUtils;
|
|
24
14
|
class RCTMGLCameraManager(private val mContext: ReactApplicationContext) :
|
|
@@ -53,15 +43,6 @@ class RCTMGLCameraManager(private val mContext: ReactApplicationContext) :
|
|
|
53
43
|
}
|
|
54
44
|
}
|
|
55
45
|
|
|
56
|
-
/*v10todo
|
|
57
|
-
@ReactProp(name="maxBounds")
|
|
58
|
-
public void setMaxBounds(RCTMGLCamera camera, String value) {
|
|
59
|
-
if (value != null) {
|
|
60
|
-
FeatureCollection collection = FeatureCollection.fromJson(value);
|
|
61
|
-
camera.setMaxBounds(GeoJSONUtils.toLatLngBounds(collection));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
*/
|
|
65
46
|
@ReactProp(name = "userTrackingMode")
|
|
66
47
|
fun setUserTrackingMode(camera: RCTMGLCamera, userTrackingMode: Int) {
|
|
67
48
|
camera.setUserTrackingMode(userTrackingMode)
|
|
@@ -108,6 +89,16 @@ class RCTMGLCameraManager(private val mContext: ReactApplicationContext) :
|
|
|
108
89
|
camera.setFollowZoomLevel(value)
|
|
109
90
|
}
|
|
110
91
|
|
|
92
|
+
@ReactProp(name = "maxBounds")
|
|
93
|
+
fun setMaxBounds(camera: RCTMGLCamera, value: String?) {
|
|
94
|
+
if (value != null) {
|
|
95
|
+
val collection = FeatureCollection.fromJson(value)
|
|
96
|
+
camera.setMaxBounds(toLatLngBounds(collection))
|
|
97
|
+
} else {
|
|
98
|
+
camera.setMaxBounds(null)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
111
102
|
companion object {
|
|
112
103
|
const val REACT_CLASS = "RCTMGLCamera"
|
|
113
104
|
}
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImages.kt
CHANGED
|
@@ -82,6 +82,7 @@ class RCTMGLImages(context: Context, private val mManager: RCTMGLImagesManager)
|
|
|
82
82
|
mNativeImages = HashMap()
|
|
83
83
|
mImages = HashMap()
|
|
84
84
|
mCurrentImages = HashSet()
|
|
85
|
+
super.removeFromMap(mapView)
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
private fun removeImages(mapView: RCTMGLMapView) {
|
|
@@ -151,6 +152,7 @@ class RCTMGLImages(context: Context, private val mManager: RCTMGLImagesManager)
|
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
override fun addToMap(mapView: RCTMGLMapView) {
|
|
155
|
+
super.addToMap(mapView)
|
|
154
156
|
// Wait for style before adding the source to the map
|
|
155
157
|
// only then we can pre-load required images / placeholders into the style
|
|
156
158
|
// before we add the ShapeSource to the map
|
|
@@ -17,13 +17,12 @@ import com.mapbox.mapboxsdk.maps.Style;
|
|
|
17
17
|
*/ class RCTMGLNativeUserLocation(context: Context?) : AbstractMapFeature(context), OnMapReadyCallback, Style.OnStyleLoaded {
|
|
18
18
|
private var mEnabled = true
|
|
19
19
|
private var mMap: MapboxMap? = null
|
|
20
|
-
private var mMapView: RCTMGLMapView? = null
|
|
21
20
|
|
|
22
21
|
@RenderMode.Mode
|
|
23
22
|
private var mRenderMode = RenderMode.COMPASS
|
|
24
23
|
override fun addToMap(mapView: RCTMGLMapView) {
|
|
24
|
+
super.addToMap(mapView)
|
|
25
25
|
mEnabled = true
|
|
26
|
-
mMapView = mapView
|
|
27
26
|
mapView.getMapboxMap()
|
|
28
27
|
mapView.getMapAsync(this)
|
|
29
28
|
setRenderMode(mRenderMode)
|
|
@@ -32,6 +31,7 @@ import com.mapbox.mapboxsdk.maps.Style;
|
|
|
32
31
|
override fun removeFromMap(mapView: RCTMGLMapView) {
|
|
33
32
|
mEnabled = false
|
|
34
33
|
mMap?.getStyle(this)
|
|
34
|
+
super.removeFromMap(mapView)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
@SuppressLint("MissingPermission")
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt
CHANGED
|
@@ -33,11 +33,14 @@ import com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
|
|
|
33
33
|
import com.mapbox.maps.plugin.annotation.generated.createPointAnnotationManager
|
|
34
34
|
import com.mapbox.maps.plugin.attribution.attribution
|
|
35
35
|
import com.mapbox.maps.plugin.attribution.generated.AttributionSettings
|
|
36
|
+
import com.mapbox.maps.plugin.scalebar.scalebar
|
|
36
37
|
import com.mapbox.maps.plugin.compass.compass
|
|
38
|
+
import com.mapbox.maps.plugin.compass.generated.CompassSettings
|
|
37
39
|
import com.mapbox.maps.plugin.delegates.listeners.*
|
|
38
40
|
import com.mapbox.maps.plugin.gestures.*
|
|
39
41
|
import com.mapbox.maps.plugin.logo.generated.LogoSettings
|
|
40
42
|
import com.mapbox.maps.plugin.logo.logo
|
|
43
|
+
import com.mapbox.maps.plugin.scalebar.generated.ScaleBarSettings
|
|
41
44
|
import com.mapbox.maps.viewannotation.ViewAnnotationManager
|
|
42
45
|
import com.mapbox.rctmgl.R
|
|
43
46
|
import com.mapbox.rctmgl.components.AbstractMapFeature
|
|
@@ -65,6 +68,12 @@ import org.json.JSONException
|
|
|
65
68
|
import org.json.JSONObject
|
|
66
69
|
import java.util.*
|
|
67
70
|
|
|
71
|
+
data class OrnamentSettings(
|
|
72
|
+
var enabled : Boolean? = false,
|
|
73
|
+
var margins: ReadableMap? =null,
|
|
74
|
+
var position: Int = -1
|
|
75
|
+
)
|
|
76
|
+
|
|
68
77
|
|
|
69
78
|
interface RCTMGLMapViewLifecycleOwner : LifecycleOwner {
|
|
70
79
|
fun handleLifecycleEvent(event: Lifecycle.Event)
|
|
@@ -608,7 +617,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
608
617
|
properties.putBoolean("isUserInteraction", mCameraChangeTracker.isUserInteraction)
|
|
609
618
|
try {
|
|
610
619
|
val bounds = mMap.coordinateBoundsForCamera(position.toCameraOptions())
|
|
611
|
-
properties.putArray("visibleBounds",
|
|
620
|
+
properties.putArray("visibleBounds", bounds.toReadableArray())
|
|
612
621
|
} catch (ex: Exception) {
|
|
613
622
|
Logger.e(LOG_TAG, "An error occurred while attempting to make the region", ex)
|
|
614
623
|
}
|
|
@@ -760,7 +769,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
760
769
|
val bounds = mMap!!.coordinateBoundsForCamera(mMap!!.cameraState.toCameraOptions())
|
|
761
770
|
|
|
762
771
|
sendResponse(callbackID, {
|
|
763
|
-
it.putArray("visibleBounds",
|
|
772
|
+
it.putArray("visibleBounds", bounds.toReadableArray())
|
|
764
773
|
})
|
|
765
774
|
}
|
|
766
775
|
|
|
@@ -858,12 +867,12 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
858
867
|
|
|
859
868
|
// region Ornaments
|
|
860
869
|
|
|
861
|
-
fun toGravity(kind: String, viewPosition: Int): Int {
|
|
870
|
+
private fun toGravity(kind: String, viewPosition: Int): Int {
|
|
862
871
|
return when (viewPosition) {
|
|
863
|
-
0 -> (Gravity.TOP or Gravity.
|
|
864
|
-
1 -> (Gravity.
|
|
865
|
-
2 -> (Gravity.
|
|
866
|
-
3 -> (Gravity.BOTTOM or Gravity.
|
|
872
|
+
0 -> (Gravity.TOP or Gravity.LEFT)
|
|
873
|
+
1 -> (Gravity.BOTTOM or Gravity.LEFT)
|
|
874
|
+
2 -> (Gravity.TOP or Gravity.RIGHT)
|
|
875
|
+
3 -> (Gravity.BOTTOM or Gravity.RIGHT)
|
|
867
876
|
else -> {
|
|
868
877
|
Logger.e(
|
|
869
878
|
"MapView",
|
|
@@ -874,13 +883,46 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
874
883
|
}
|
|
875
884
|
}
|
|
876
885
|
|
|
877
|
-
|
|
886
|
+
private fun updateOrnament(kind: String, from: OrnamentSettings, to: GenericOrnamentSettings) {
|
|
887
|
+
from.enabled?.let { to.enabled = it }
|
|
888
|
+
if (from.position >= 0) {
|
|
889
|
+
to.position = toGravity(kind, from.position)
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
from.margins?.let {
|
|
893
|
+
val pixelDensity = resources.displayMetrics.density
|
|
894
|
+
val x: Int? = it.getDouble("x")?.let { (it * pixelDensity).toInt() }
|
|
895
|
+
val y: Int? = it.getDouble("y")?.let { (it * pixelDensity).toInt() }
|
|
896
|
+
|
|
897
|
+
val horizontalGravity = to.position and Gravity.HORIZONTAL_GRAVITY_MASK
|
|
898
|
+
val verticalGravity = to.position and Gravity.VERTICAL_GRAVITY_MASK
|
|
899
|
+
|
|
900
|
+
when (horizontalGravity) {
|
|
901
|
+
Gravity.LEFT -> { to.setHMargins(x?.toFloat(), 0f) }
|
|
902
|
+
Gravity.RIGHT -> { to.setHMargins(0f, x?.toFloat()) }
|
|
903
|
+
Gravity.CENTER_HORIZONTAL ->{ to.setHMargins(x?.toFloat(), x?.toFloat()) }
|
|
904
|
+
else -> Logger.e(
|
|
905
|
+
"MapView",
|
|
906
|
+
"${kind}ViewMargins: unexpected absolute pos: $horizontalGravity"
|
|
907
|
+
)
|
|
908
|
+
}
|
|
909
|
+
when (verticalGravity) {
|
|
910
|
+
Gravity.TOP -> { to.setVMargins(y?.toFloat(), 0f) }
|
|
911
|
+
Gravity.BOTTOM -> { to.setVMargins(0f, y?.toFloat()) }
|
|
912
|
+
Gravity.CENTER_VERTICAL -> { to.setVMargins(y?.toFloat(), y?.toFloat()) }
|
|
913
|
+
else -> Logger.e(
|
|
914
|
+
"MapView",
|
|
915
|
+
"${kind}ViewMargins: unexpected vertical pos: $verticalGravity"
|
|
916
|
+
)
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
var mCompassSettings = OrnamentSettings(enabled = false)
|
|
878
922
|
var mCompassFadeWhenNorth = false
|
|
879
|
-
var mCompassViewMargins: ReadableMap? = null
|
|
880
|
-
var mCompassViewPosition: Int = -1
|
|
881
923
|
|
|
882
924
|
fun setReactCompassEnabled(compassEnabled: Boolean) {
|
|
883
|
-
|
|
925
|
+
mCompassSettings.enabled = compassEnabled
|
|
884
926
|
updateCompass()
|
|
885
927
|
}
|
|
886
928
|
|
|
@@ -890,82 +932,55 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
890
932
|
}
|
|
891
933
|
|
|
892
934
|
fun setReactCompassViewMargins(compassViewMargins: ReadableMap) {
|
|
893
|
-
|
|
935
|
+
mCompassSettings.margins = compassViewMargins
|
|
894
936
|
updateCompass()
|
|
895
937
|
}
|
|
896
938
|
|
|
897
939
|
fun setReactCompassViewPosition(compassViewPosition: Int) {
|
|
898
|
-
|
|
940
|
+
mCompassSettings.position = compassViewPosition
|
|
899
941
|
updateCompass()
|
|
900
942
|
}
|
|
901
943
|
|
|
902
|
-
fun
|
|
903
|
-
|
|
904
|
-
val right_mask = 2;
|
|
905
|
-
|
|
906
|
-
var margins = WritableNativeMap()
|
|
907
|
-
var position = 0;
|
|
908
|
-
if (compassMargins.hasKey("bottom")) {
|
|
909
|
-
margins.putInt("y", compassMargins.getInt("bottom"))
|
|
910
|
-
position = position or bottom_mask
|
|
911
|
-
} else {
|
|
912
|
-
if (compassMargins.hasKey("top")) {
|
|
913
|
-
margins.putInt("y", compassMargins.getInt("top"))
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
if (compassMargins.hasKey("left")) {
|
|
918
|
-
margins.putInt("x", compassMargins.getInt("left"))
|
|
919
|
-
} else {
|
|
920
|
-
if (compassMargins.hasKey("right")) {
|
|
921
|
-
margins.putInt("x", compassMargins.getInt("right"))
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
mCompassViewPosition = position
|
|
925
|
-
mCompassViewMargins = margins
|
|
944
|
+
fun setReactCompassPosition(compassPosition: ReadableMap) {
|
|
945
|
+
mCompassSettings.setPosAndMargins(compassPosition)
|
|
926
946
|
updateCompass()
|
|
927
947
|
}
|
|
928
948
|
|
|
929
949
|
private fun updateCompass() {
|
|
930
950
|
compass.updateSettings {
|
|
931
|
-
enabled = mCompassEnabled
|
|
932
951
|
fadeWhenFacingNorth = mCompassFadeWhenNorth
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
952
|
+
updateOrnament("compass", mCompassSettings, this.toGenericOrnamentSettings())
|
|
953
|
+
}
|
|
954
|
+
}
|
|
936
955
|
|
|
937
|
-
|
|
938
|
-
if (compassViewMargins != null) {
|
|
939
|
-
val pixelDensity = resources.displayMetrics.density.toInt()
|
|
940
|
-
val x: Int = compassViewMargins.getInt("x") * pixelDensity
|
|
941
|
-
val y: Int = compassViewMargins.getInt("y") * pixelDensity
|
|
956
|
+
var mScaleBarSettings = OrnamentSettings(enabled = false)
|
|
942
957
|
|
|
943
|
-
|
|
944
|
-
|
|
958
|
+
fun setReactScaleBarEnabled(scaleBarEnabled: Boolean) {
|
|
959
|
+
mScaleBarSettings.enabled = scaleBarEnabled
|
|
960
|
+
updateScaleBar()
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
fun setReactScaleBarViewMargins(scaleBarMargins: ReadableMap) {
|
|
964
|
+
mScaleBarSettings.margins = scaleBarMargins
|
|
965
|
+
updateScaleBar()
|
|
966
|
+
}
|
|
945
967
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
Gravity.BOTTOM -> marginBottom = y.toFloat()
|
|
960
|
-
Gravity.CENTER_VERTICAL -> marginTop = y.toFloat()
|
|
961
|
-
else -> Logger.e(
|
|
962
|
-
"MapView",
|
|
963
|
-
"compassViewMargins: unexpected vertical pos: $verticalGravity"
|
|
964
|
-
)
|
|
965
|
-
}
|
|
966
|
-
}
|
|
968
|
+
fun setReactScaleBarViewPosition(scaleBarPosition: Int) {
|
|
969
|
+
mScaleBarSettings.position = scaleBarPosition
|
|
970
|
+
updateScaleBar()
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
fun setReactScaleBarPosition(scaleBarPosition: ReadableMap) {
|
|
974
|
+
mScaleBarSettings.setPosAndMargins(scaleBarPosition)
|
|
975
|
+
updateScaleBar()
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
private fun updateScaleBar() {
|
|
979
|
+
scalebar.updateSettings {
|
|
980
|
+
updateOrnament("scaleBar", mScaleBarSettings, this.toGenericOrnamentSettings())
|
|
967
981
|
}
|
|
968
982
|
}
|
|
983
|
+
|
|
969
984
|
// endregion
|
|
970
985
|
|
|
971
986
|
private fun getGravityAndMargin (position:ReadableMap): Pair<Int, IntArray> {
|
|
@@ -1043,6 +1058,44 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1043
1058
|
private var mLogoGravity: Int? = null
|
|
1044
1059
|
private var mLogoMargin: IntArray? = null
|
|
1045
1060
|
|
|
1061
|
+
var mLogoSettings = OrnamentSettings(enabled = null)
|
|
1062
|
+
|
|
1063
|
+
fun setReactLogoEnabled(enabled: Boolean?) {
|
|
1064
|
+
mLogoSettings.enabled = enabled
|
|
1065
|
+
updateLogo()
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
fun setReactLogoMargins(margins: ReadableMap) {
|
|
1069
|
+
mLogoSettings.margins = margins
|
|
1070
|
+
updateLogo()
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
fun setReactLogoViewPosition(position: Int) {
|
|
1074
|
+
mLogoSettings.position = position
|
|
1075
|
+
updateLogo()
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
fun setReactLogoPosition(position: ReadableMap?) {
|
|
1079
|
+
mLogoSettings.setPosAndMargins(position)
|
|
1080
|
+
updateLogo()
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
private fun updateLogo() {
|
|
1084
|
+
logo.updateSettings {
|
|
1085
|
+
updateOrnament("logo", mLogoSettings, this.toGenericOrnamentSettings())
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
logo.updateSettings {
|
|
1089
|
+
println(String.format("logo :: position - before 0x%08x", position))
|
|
1090
|
+
//position = Gravity.BOTTOM or Gravity.RIGHT
|
|
1091
|
+
println(String.format("eq bottom|right %b", position == (Gravity.BOTTOM or Gravity.RIGHT)))
|
|
1092
|
+
if (position == Gravity.BOTTOM or Gravity.RIGHT) {
|
|
1093
|
+
position = Gravity.BOTTOM or Gravity.RIGHT
|
|
1094
|
+
}
|
|
1095
|
+
println(String.format("logo :: position - after 0x%08x", position))
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
/*
|
|
1046
1099
|
fun setReactLogoEnabled(logoEnabled: Boolean?) {
|
|
1047
1100
|
mLogoEnabled = logoEnabled ?: LogoSettings().enabled
|
|
1048
1101
|
updateLogo()
|
|
@@ -1081,6 +1134,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1081
1134
|
}
|
|
1082
1135
|
}
|
|
1083
1136
|
}
|
|
1137
|
+
*/
|
|
1084
1138
|
// endregion
|
|
1085
1139
|
|
|
1086
1140
|
// region lifecycle
|
|
@@ -1128,3 +1182,97 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
1128
1182
|
|
|
1129
1183
|
// endregion
|
|
1130
1184
|
}
|
|
1185
|
+
|
|
1186
|
+
fun OrnamentSettings.setPosAndMargins(posAndMargins: ReadableMap?) {
|
|
1187
|
+
if (posAndMargins == null) { return }
|
|
1188
|
+
|
|
1189
|
+
val bottom_mask = 1;
|
|
1190
|
+
val right_mask = 2;
|
|
1191
|
+
|
|
1192
|
+
var margins = WritableNativeMap()
|
|
1193
|
+
var position = 0;
|
|
1194
|
+
if (posAndMargins
|
|
1195
|
+
.hasKey("bottom")) {
|
|
1196
|
+
margins.putInt("y", posAndMargins.getInt("bottom"))
|
|
1197
|
+
position = position or bottom_mask
|
|
1198
|
+
} else {
|
|
1199
|
+
if (posAndMargins.hasKey("top")) {
|
|
1200
|
+
margins.putInt("y", posAndMargins.getInt("top"))
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
if (posAndMargins.hasKey("left")) {
|
|
1205
|
+
margins.putInt("x", posAndMargins.getInt("left"))
|
|
1206
|
+
} else {
|
|
1207
|
+
if (posAndMargins.hasKey("right")) {
|
|
1208
|
+
position = position or right_mask
|
|
1209
|
+
margins.putInt("x", posAndMargins.getInt("right"))
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
this.position = position
|
|
1213
|
+
this.margins = margins
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
interface GenericOrnamentSettings {
|
|
1217
|
+
fun setHMargins(left: Float?, right: Float?)
|
|
1218
|
+
fun setVMargins(top: Float?, bottom: Float?)
|
|
1219
|
+
var enabled: Boolean
|
|
1220
|
+
var position: Int
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
fun ScaleBarSettings.toGenericOrnamentSettings() = object : GenericOrnamentSettings {
|
|
1224
|
+
private val settings = this@toGenericOrnamentSettings
|
|
1225
|
+
override fun setHMargins(left: Float?, right: Float?) {
|
|
1226
|
+
left?.let { settings.marginLeft = it }
|
|
1227
|
+
right?.let { settings.marginRight = it }
|
|
1228
|
+
}
|
|
1229
|
+
override fun setVMargins(top: Float?, bottom: Float?) {
|
|
1230
|
+
top?.let { settings.marginTop = it }
|
|
1231
|
+
bottom?.let { settings.marginBottom = it }
|
|
1232
|
+
}
|
|
1233
|
+
override var enabled: Boolean
|
|
1234
|
+
get() = settings.enabled
|
|
1235
|
+
set(value) { settings.enabled = value }
|
|
1236
|
+
override var position: Int
|
|
1237
|
+
get() = settings.position
|
|
1238
|
+
set(value) { settings.position = value }
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
fun CompassSettings.toGenericOrnamentSettings() = object : GenericOrnamentSettings {
|
|
1242
|
+
private val settings = this@toGenericOrnamentSettings
|
|
1243
|
+
override fun setHMargins(left: Float?, right: Float?) {
|
|
1244
|
+
left?.let { settings.marginLeft = it }
|
|
1245
|
+
right?.let { settings.marginRight = it }
|
|
1246
|
+
}
|
|
1247
|
+
override fun setVMargins(top: Float?, bottom: Float?) {
|
|
1248
|
+
top?.let { settings.marginTop = it }
|
|
1249
|
+
bottom?.let { settings.marginBottom = it }
|
|
1250
|
+
}
|
|
1251
|
+
override var enabled: Boolean
|
|
1252
|
+
get() = settings.enabled
|
|
1253
|
+
set(value) { settings.enabled = value }
|
|
1254
|
+
override var position: Int
|
|
1255
|
+
get() = settings.position
|
|
1256
|
+
set(value) { settings.position = value }
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
fun LogoSettings.toGenericOrnamentSettings() = object : GenericOrnamentSettings {
|
|
1260
|
+
private val settings = this@toGenericOrnamentSettings
|
|
1261
|
+
override fun setHMargins(left: Float?, right: Float?) {
|
|
1262
|
+
left?.let { settings.marginLeft = it }
|
|
1263
|
+
right?.let { settings.marginRight = it }
|
|
1264
|
+
}
|
|
1265
|
+
override fun setVMargins(top: Float?, bottom: Float?) {
|
|
1266
|
+
top?.let { settings.marginTop = it }
|
|
1267
|
+
bottom?.let { settings.marginBottom = it }
|
|
1268
|
+
}
|
|
1269
|
+
override var enabled: Boolean
|
|
1270
|
+
get() = settings.enabled
|
|
1271
|
+
set(value) { settings.enabled = value }
|
|
1272
|
+
override var position: Int
|
|
1273
|
+
get() = settings.position
|
|
1274
|
+
set(value) {
|
|
1275
|
+
println(String.format("logo :: position: 0x%08x", value))
|
|
1276
|
+
settings.position = value
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
@@ -136,6 +136,26 @@ open class RCTMGLMapViewManager(context: ReactApplicationContext?) :
|
|
|
136
136
|
mapView!!.setReactLogoPosition(logoPosition);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
@ReactProp(name = "scaleBarEnabled")
|
|
140
|
+
fun setScaleBarEnabled(mapView: RCTMGLMapView?, scaleBarEnabled: Boolean) {
|
|
141
|
+
mapView!!.setReactScaleBarEnabled(scaleBarEnabled);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@ReactProp(name = "scaleBarViewMargins")
|
|
145
|
+
fun setScaleBarViewMargins(mapView: RCTMGLMapView?, scaleBarMargins: ReadableMap?) {
|
|
146
|
+
mapView!!.setReactScaleBarViewMargins(scaleBarMargins!!);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@ReactProp(name = "scaleBarViewPosition")
|
|
150
|
+
fun setScaleBarViewPosition(mapView: RCTMGLMapView?, scaleBarPosition: Int) {
|
|
151
|
+
mapView!!.setReactScaleBarViewPosition(scaleBarPosition!!)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@ReactProp(name = "scaleBarPosition")
|
|
155
|
+
fun scaleBarViewPosition(mapView: RCTMGLMapView?, scaleBarPosition: ReadableMap) {
|
|
156
|
+
mapView!!.setReactScaleBarPosition(scaleBarPosition)
|
|
157
|
+
}
|
|
158
|
+
|
|
139
159
|
@ReactProp(name = "compassEnabled")
|
|
140
160
|
fun setCompassEnabled(mapView: RCTMGLMapView?, compassEnabled: Boolean) {
|
|
141
161
|
mapView!!.setReactCompassEnabled(compassEnabled);
|
|
@@ -157,8 +177,8 @@ open class RCTMGLMapViewManager(context: ReactApplicationContext?) :
|
|
|
157
177
|
}
|
|
158
178
|
|
|
159
179
|
@ReactProp(name = "compassPosition")
|
|
160
|
-
fun
|
|
161
|
-
mapView!!.
|
|
180
|
+
fun setCompassPosition(mapView: RCTMGLMapView?, compassMargins: ReadableMap) {
|
|
181
|
+
mapView!!.setReactCompassPosition(compassMargins)
|
|
162
182
|
}
|
|
163
183
|
|
|
164
184
|
@ReactProp(name = "contentInset")
|