@rnmapbox/maps 10.0.0-beta.34 → 10.0.0-beta.35

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/README.md CHANGED
@@ -65,9 +65,9 @@ At the moment, the following implementations are supported:
65
65
 
66
66
  |*RNMapboxMapsImpl*|*Notes*|
67
67
  |----------------|-----|
68
- |mapbox|New [Mapbox v10](https://www.mapbox.com/mobile-maps-sdk) implementation (BETA)|
69
- |maplibre|[MapLibre](https://github.com/maplibre/maplibre-gl-native) opensource fork of Mapbox SDKs|
70
- |mapbox-gl|Legacy mapbox implementation [iOS](https://docs.mapbox.com/android/legacy/maps/guides/) [Android](https://docs.mapbox.com/ios/legacy/maps/guides/)|
68
+ |mapbox|New [Mapbox v10](https://www.mapbox.com/mobile-maps-sdk) implementation - recommended|
69
+ |maplibre|[MapLibre](https://github.com/maplibre/maplibre-gl-native) opensource fork of Mapbox SDKs - will be dropped in next version|
70
+ |mapbox-gl|Legacy mapbox implementation [iOS](https://docs.mapbox.com/android/legacy/maps/guides/) [Android](https://docs.mapbox.com/ios/legacy/maps/guides/) - legacy, will be dropped in next version|
71
71
 
72
72
  _See [iOS](ios/install.md) & [Android](android/install.md) setup guide for more details on setting `RNMapboxMapsImpl`_
73
73
 
@@ -130,7 +130,7 @@ dependencies {
130
130
  implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:5.1.0'
131
131
  }
132
132
  else if (safeExtGet("RNMapboxMapsImpl", defaultMapboxMapsImpl) == "mapbox") {
133
- implementation 'com.mapbox.maps:android:10.7.0'
133
+ implementation 'com.mapbox.maps:android:10.8.0'
134
134
  implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:6.4.0'
135
135
  }
136
136
  }
@@ -10,6 +10,7 @@ import java.util.ArrayList;
10
10
  import java.util.Collections;
11
11
  import java.util.List;
12
12
 
13
+ import com.mapbox.rctmgl.components.annotation.RCTMGLMarkerViewWrapperManager;
13
14
  import com.mapbox.rctmgl.components.camera.RCTMGLCameraManager;
14
15
 
15
16
  import com.mapbox.rctmgl.components.annotation.RCTMGLCalloutManager;
@@ -76,12 +77,13 @@ public class RCTMGLPackage implements ReactPackage {
76
77
  managers.add(new RCTMGLCameraManager(reactApplicationContext));
77
78
  managers.add(new RCTMGLAndroidTextureMapViewManager(reactApplicationContext));
78
79
  managers.add(new RCTMGLMapViewManager(reactApplicationContext));
79
- managers.add(new RCTMGLMarkerViewManager(reactApplicationContext));
80
-
81
- managers.add(new RCTMGLLightManager());
82
80
 
81
+ // annotations
82
+ managers.add(new RCTMGLMarkerViewManager(reactApplicationContext));
83
+ managers.add(new RCTMGLMarkerViewWrapperManager(reactApplicationContext));
83
84
  managers.add(new RCTMGLPointAnnotationManager(reactApplicationContext));
84
85
  managers.add(new RCTMGLCalloutManager());
86
+
85
87
  managers.add(new RCTMGLNativeUserLocationManager());
86
88
 
87
89
  // sources
@@ -106,6 +108,9 @@ public class RCTMGLPackage implements ReactPackage {
106
108
  managers.add(new RCTMGLSkyLayerManager());
107
109
  managers.add(new RCTMGLTerrainManager());
108
110
  managers.add(new RCTMGLBackgroundLayerManager());
111
+
112
+ managers.add(new RCTMGLLightManager());
113
+
109
114
  return managers;
110
115
  }
111
116
  }
@@ -4,17 +4,15 @@ import android.content.Context
4
4
  import android.view.View
5
5
  import com.mapbox.geojson.Point
6
6
  import com.mapbox.maps.ViewAnnotationOptions
7
- import com.mapbox.rctmgl.components.mapview.OnMapReadyCallback
8
- import com.mapbox.maps.MapboxMap
9
7
  import com.mapbox.rctmgl.components.AbstractMapFeature
10
8
  import com.mapbox.rctmgl.components.mapview.RCTMGLMapView
11
- import com.mapbox.rctmgl.utils.GeoJSONUtils
12
9
 
13
10
  class RCTMGLMarkerView(context: Context?, private val mManager: RCTMGLMarkerViewManager) : AbstractMapFeature(context), View.OnLayoutChangeListener {
14
11
  private var mMapView: RCTMGLMapView? = null
15
12
  private var mChildView: View? = null
16
13
  private var mCoordinate: Point? = null
17
14
  private lateinit var mAnchor: Array<Float>
15
+
18
16
  override fun addView(childView: View, childPosition: Int) {
19
17
  mChildView = childView
20
18
  }
@@ -61,15 +59,26 @@ class RCTMGLMarkerView(context: Context?, private val mManager: RCTMGLMarkerView
61
59
  }
62
60
 
63
61
  override fun removeFromMap(mapView: RCTMGLMapView) {
64
- if (mChildView != null) {
65
- mMapView?.viewAnnotationManager?.removeViewAnnotation(mChildView!!)
66
- mChildView!!.removeOnLayoutChangeListener(this)
62
+ val childView = mChildView
63
+ if (childView != null) {
64
+ childView.removeOnLayoutChangeListener(this)
65
+ childView.visibility = INVISIBLE;
66
+ mMapView?.viewAnnotationManager?.removeViewAnnotation(childView)
67
67
  }
68
68
  }
69
69
 
70
70
  override fun onLayoutChange(v: View, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int,
71
71
  oldRight: Int, oldBottom: Int) {
72
72
  if (left != oldLeft || right != oldRight || top != oldTop || bottom != oldBottom) {
73
+ val centerX = oldLeft + (oldRight-oldLeft)*mAnchor[0];
74
+ val centerY = oldTop + (oldBottom-oldTop)*mAnchor[1];
75
+
76
+ val newLeft = (centerX - (mAnchor[0] * (right - left))).toInt();
77
+ val newTop = (centerY - (mAnchor[1] * (bottom - top))).toInt();
78
+
79
+ val childView = mChildView!!
80
+ childView.x = (newLeft - oldLeft) + childView.x;
81
+ childView.y = (newTop-oldTop) + childView.y;
73
82
  refresh()
74
83
  }
75
84
  }
@@ -0,0 +1,40 @@
1
+ package com.mapbox.rctmgl.components.annotation
2
+
3
+ import android.view.View
4
+ import com.mapbox.rctmgl.utils.GeoJSONUtils.toPointGeometry
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.mapbox.rctmgl.components.AbstractEventEmitter
7
+ import com.facebook.react.uimanager.annotations.ReactProp
8
+ import com.facebook.react.bridge.ReadableMap
9
+ import com.facebook.react.common.MapBuilder
10
+ import com.facebook.react.uimanager.ThemedReactContext
11
+
12
+ class RCTMGLMarkerViewManager(reactApplicationContext: ReactApplicationContext?) :
13
+ AbstractEventEmitter<RCTMGLMarkerView?>(reactApplicationContext) {
14
+ override fun getName(): String {
15
+ return REACT_CLASS
16
+ }
17
+
18
+ @ReactProp(name = "coordinate")
19
+ fun setCoordinate(markerView: RCTMGLMarkerView, geoJSONStr: String?) {
20
+ markerView.setCoordinate(toPointGeometry(geoJSONStr))
21
+ }
22
+
23
+ @ReactProp(name = "anchor")
24
+ fun setAnchor(markerView: RCTMGLMarkerView, map: ReadableMap) {
25
+ markerView.setAnchor(map.getDouble("x").toFloat(), map.getDouble("y").toFloat())
26
+ }
27
+
28
+ override fun createViewInstance(reactContext: ThemedReactContext): RCTMGLMarkerView {
29
+ return RCTMGLMarkerView(reactContext, this)
30
+ }
31
+
32
+ override fun customEvents(): Map<String, String>? {
33
+ return MapBuilder.builder<String, String>()
34
+ .build()
35
+ }
36
+
37
+ companion object {
38
+ const val REACT_CLASS = "RCTMGLMarkerView"
39
+ }
40
+ }
@@ -0,0 +1,8 @@
1
+ package com.mapbox.rctmgl.components.annotation
2
+ import android.content.Context
3
+ import android.util.Log
4
+ import android.view.View
5
+ import com.facebook.react.views.view.ReactViewGroup
6
+
7
+ class RCTMGLMarkerViewWrapper(context: Context?, private val mManager: RCTMGLMarkerViewWrapperManager) : ReactViewGroup(context) {
8
+ }
@@ -0,0 +1,21 @@
1
+ package com.mapbox.rctmgl.components.annotation
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.uimanager.ThemedReactContext
5
+ import com.facebook.react.uimanager.ViewGroupManager
6
+
7
+ class RCTMGLMarkerViewWrapperManager(reactApplicationContext: ReactApplicationContext?) :
8
+ ViewGroupManager<RCTMGLMarkerViewWrapper>() {
9
+
10
+ override fun getName(): String {
11
+ return REACT_CLASS
12
+ }
13
+
14
+ override fun createViewInstance(reactContext: ThemedReactContext): RCTMGLMarkerViewWrapper {
15
+ return RCTMGLMarkerViewWrapper(reactContext, this)
16
+ }
17
+
18
+ companion object {
19
+ const val REACT_CLASS = "RCTMGLMarkerViewWrapper"
20
+ }
21
+ }
@@ -8,6 +8,10 @@ import android.view.Gravity
8
8
  import android.view.View
9
9
  import android.view.ViewGroup
10
10
  import android.widget.FrameLayout
11
+ import androidx.lifecycle.Lifecycle
12
+ import androidx.lifecycle.LifecycleOwner
13
+ import androidx.lifecycle.LifecycleRegistry
14
+ import androidx.lifecycle.ViewTreeLifecycleOwner
11
15
  import com.facebook.react.bridge.*
12
16
  import com.mapbox.android.gestures.MoveGestureDetector
13
17
  import com.mapbox.geojson.Feature
@@ -467,6 +471,23 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
467
471
  return false
468
472
  }
469
473
 
474
+ override fun onAttachedToWindow() {
475
+ val hostingLifecycleOwner = ViewTreeLifecycleOwner.get(this)
476
+ if (hostingLifecycleOwner == null) {
477
+ ViewTreeLifecycleOwner.set(this, object : LifecycleOwner {
478
+ private lateinit var lifecycleRegistry: LifecycleRegistry
479
+ init {
480
+ lifecycleRegistry = LifecycleRegistry(this)
481
+ lifecycleRegistry.currentState = Lifecycle.State.CREATED
482
+ }
483
+ override fun getLifecycle(): Lifecycle {
484
+ return lifecycleRegistry
485
+ }
486
+ })
487
+ }
488
+ super.onAttachedToWindow()
489
+ }
490
+
470
491
  override fun onMapLongClick(point: Point): Boolean {
471
492
  val _this = this
472
493
  if (mAnnotationDragged) {
@@ -96,6 +96,7 @@ class RCTMGLModule(private val mReactContext: ReactApplicationContext) : ReactCo
96
96
  val locationModuleCallbackNames: MutableMap<String, String> = HashMap()
97
97
  locationModuleCallbackNames["Update"] = RCTMGLLocationModule.LOCATION_UPDATE
98
98
  return MapBuilder.builder<String, Any>()
99
+ .put("MapboxV10", true)
99
100
  .put("StyleURL", styleURLS)
100
101
  .put("EventTypes", eventTypes)
101
102
  .put("StyleSource", styleSourceConsts)
package/ios/install.md CHANGED
@@ -12,6 +12,7 @@ The following is required for every following setup
12
12
 
13
13
  Add the following to your `ios/Podfile`:
14
14
 
15
+
15
16
  ```ruby
16
17
  pre_install do |installer|
17
18
  $RNMapboxMaps.pre_install(installer)
@@ -26,7 +27,9 @@ Add the following to your `ios/Podfile`:
26
27
  end
27
28
  ```
28
29
 
29
- Running `pod install` will add MapLibre SDK via SwiftPackageManager
30
+ We also recommend setting the `$RNMapboxMapsImpl` to `mapbox` aka v10 implementation [see bellow for detailed instructions](#mapbox-maps-sdk-v10)
31
+
32
+ Running `pod install` download the proper mapbox dependency
30
33
 
31
34
  ```sh
32
35
  # Go to the ios folder
@@ -42,6 +45,27 @@ Read on if you want to edit your Mapbox version or flavor.
42
45
 
43
46
  <br>
44
47
 
48
+ ## Mapbox Maps SDK (v10)
49
+
50
+ This is the version we recommend, while other implementations should work, we don't plan to support them in next version.
51
+
52
+ Check the current version of the SDK [here](https://docs.mapbox.com/ios/maps/overview/).
53
+
54
+ Add the following to the beginning of your podfile
55
+ ```ruby
56
+ $RNMapboxMapsImpl = 'mapbox'
57
+ ```
58
+
59
+ You can also specify the version to use. *Warning:* if you set a version, then later update, the `rnamapbox/maps` library it's possible that you'll end up using Mapbox older version than supported. Make sure you revise this value with `rnmapbox/maps` updates.
60
+
61
+ ```ruby
62
+ $RNMapboxMapsVersion = '~> 10.9.0'
63
+ ```
64
+
65
+ You will need to authorize your download of the Maps SDK with a secret access token with the `DOWNLOADS:READ` scope. This [guide](https://docs.mapbox.com/ios/maps/guides/install/#configure-credentials) explains how to configure the secret token under section `Configure your secret token`.
66
+
67
+ <br/>
68
+
45
69
  ## Maplibre
46
70
 
47
71
  [MapLibre](https://github.com/maplibre/maplibre-gl-native) is an OSS fork of MapboxGL
@@ -72,19 +96,6 @@ $RNMapboxMapsSwiftPackageManager = {
72
96
 
73
97
  <br/>
74
98
 
75
- ## Mapbox Maps SDK (v10)
76
-
77
- Check the current version of the SDK [here](https://docs.mapbox.com/ios/maps/overview/).
78
-
79
- ```ruby
80
- $RNMapboxMapsImpl = 'mapbox'
81
- $RNMapboxMapsVersion = '~> 10.6.0'
82
- ```
83
-
84
- You will need to authorize your download of the Maps SDK with a secret access token with the `DOWNLOADS:READ` scope. This [guide](https://docs.mapbox.com/ios/maps/guides/install/#configure-credentials) explains how to configure the secret token under section `Configure your secret token`.
85
-
86
- <br/>
87
-
88
99
  ## Mapbox Maps GL SDK (9.0 or earlier)
89
100
 
90
101
  This is the old version of mapbox gl (deprecated)
@@ -4,7 +4,6 @@ import {
4
4
  processColor,
5
5
  ProcessedColorValue,
6
6
  } from 'react-native';
7
- import { UsesNonExemptEncryption } from '@expo/config-plugins/build/ios';
8
7
 
9
8
  import { getStyleType } from './styleMap';
10
9
  import BridgeValue, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rnmapbox/maps",
3
3
  "description": "A Mapbox react native module for creating custom maps",
4
- "version": "10.0.0-beta.34",
4
+ "version": "10.0.0-beta.35",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -20,7 +20,7 @@ require 'json'
20
20
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
21
21
 
22
22
  ## Warning: these lines are scanned by autogenerate.js
23
- rnMapboxMapsDefaultMapboxVersion = '~> 10.7.0'
23
+ rnMapboxMapsDefaultMapboxVersion = '~> 10.8.1'
24
24
  rnMapboxMapsDefaultMapboxGLVersion = '~> 5.9.0'
25
25
  rnMapboxMapsDefaultMapLibreVersion = 'exactVersion 5.12.1'
26
26
 
@@ -1,45 +0,0 @@
1
- package com.mapbox.rctmgl.components.annotation;
2
-
3
- import com.facebook.react.bridge.ReactApplicationContext;
4
- import com.facebook.react.bridge.ReadableMap;
5
- import com.facebook.react.common.MapBuilder;
6
- import com.facebook.react.uimanager.ThemedReactContext;
7
- import com.facebook.react.uimanager.annotations.ReactProp;
8
- import com.mapbox.rctmgl.components.AbstractEventEmitter;
9
- import com.mapbox.rctmgl.utils.GeoJSONUtils;
10
-
11
- import java.util.Map;
12
-
13
- public class RCTMGLMarkerViewManager extends AbstractEventEmitter<RCTMGLMarkerView> {
14
- public static final String REACT_CLASS = "RCTMGLMarkerView";
15
-
16
- public RCTMGLMarkerViewManager(ReactApplicationContext reactApplicationContext) {
17
- super(reactApplicationContext);
18
- }
19
-
20
- @Override
21
- public String getName() {
22
- return REACT_CLASS;
23
- }
24
-
25
- @ReactProp(name="coordinate")
26
- public void setCoordinate(RCTMGLMarkerView markerView, String geoJSONStr) {
27
- markerView.setCoordinate(GeoJSONUtils.toPointGeometry(geoJSONStr));
28
- }
29
-
30
- @ReactProp(name="anchor")
31
- public void setAnchor(RCTMGLMarkerView markerView, ReadableMap map) {
32
- markerView.setAnchor((float) map.getDouble("x"), (float) map.getDouble("y"));
33
- }
34
-
35
- @Override
36
- protected RCTMGLMarkerView createViewInstance(ThemedReactContext reactContext) {
37
- return new RCTMGLMarkerView(reactContext, this);
38
- }
39
-
40
- @Override
41
- public Map<String, String> customEvents() {
42
- return MapBuilder.<String, String>builder()
43
- .build();
44
- }
45
- }