react-native-maps 1.21.0-alpha.135 → 1.21.0-alpha.137

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.
@@ -0,0 +1,124 @@
1
+ package com.rnmaps.fabric;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+
6
+ import com.facebook.react.bridge.ReactApplicationContext;
7
+ import com.facebook.react.module.annotations.ReactModule;
8
+ import com.facebook.react.uimanager.ThemedReactContext;
9
+ import com.facebook.react.uimanager.ViewGroupManager;
10
+ import com.facebook.react.uimanager.ViewManagerDelegate;
11
+ import com.facebook.react.viewmanagers.RNMapsUrlTileManagerDelegate;
12
+ import com.facebook.react.viewmanagers.RNMapsUrlTileManagerInterface;
13
+ import com.rnmaps.maps.MapPolyline;
14
+ import com.rnmaps.maps.MapUrlTile;
15
+
16
+ import java.util.HashMap;
17
+ import java.util.Map;
18
+
19
+ @ReactModule(name = UrlTileManager.REACT_CLASS)
20
+ public class UrlTileManager extends ViewGroupManager<MapUrlTile> implements RNMapsUrlTileManagerInterface<MapUrlTile> {
21
+ public static final String REACT_CLASS = "RNMapsUrlTile";
22
+
23
+ public UrlTileManager(ReactApplicationContext context) {
24
+ super(context);
25
+ }
26
+
27
+ private final RNMapsUrlTileManagerDelegate<MapUrlTile, UrlTileManager> delegate =
28
+ new RNMapsUrlTileManagerDelegate<>(this);
29
+
30
+ @Override
31
+ public ViewManagerDelegate<MapUrlTile> getDelegate() {
32
+ return delegate;
33
+ }
34
+
35
+ @Override
36
+ public String getName() {
37
+ return REACT_CLASS;
38
+ }
39
+
40
+ @Override
41
+ public MapUrlTile createViewInstance(ThemedReactContext context) {
42
+ return new MapUrlTile(context);
43
+ }
44
+
45
+
46
+ @Nullable
47
+ @Override
48
+ public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
49
+ return new HashMap<>();
50
+ }
51
+
52
+ @Nullable
53
+ @Override
54
+ public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
55
+ return new HashMap<>();
56
+ }
57
+
58
+ @Override
59
+ public void setDoubleTileSize(MapUrlTile view, boolean value) {
60
+ view.setDoubleTileSize(value);
61
+ }
62
+
63
+ @Override
64
+ public void setFlipY(MapUrlTile view, boolean value) {
65
+ view.setFlipY(value);
66
+ }
67
+
68
+ @Override
69
+ public void setMaximumNativeZ(MapUrlTile view, int value) {
70
+ view.setMaximumNativeZ(value);
71
+ }
72
+
73
+ @Override
74
+ public void setMaximumZ(MapUrlTile view, int value) {
75
+ view.setMaximumZ(value);
76
+ }
77
+
78
+ @Override
79
+ public void setMinimumZ(MapUrlTile view, int value) {
80
+ view.setMinimumZ(value);
81
+ }
82
+
83
+ @Override
84
+ public void setOfflineMode(MapUrlTile view, boolean value) {
85
+ view.setOfflineMode(value);
86
+ }
87
+
88
+ @Override
89
+ public void setShouldReplaceMapContent(MapUrlTile view, boolean value) {
90
+ // not supported
91
+
92
+ }
93
+ @Override
94
+ public void setZIndex(@NonNull MapUrlTile view, float zIndex) {
95
+ super.setZIndex(view, zIndex);
96
+ view.setZIndex(zIndex);
97
+ }
98
+
99
+ @Override
100
+ public void setOpacity(@NonNull MapUrlTile view, float opacity) {
101
+ super.setOpacity(view, opacity);
102
+ view.setOpacity(opacity);
103
+ }
104
+
105
+ @Override
106
+ public void setTileCacheMaxAge(MapUrlTile view, int value) {
107
+ view.setTileCacheMaxAge(value);
108
+ }
109
+
110
+ @Override
111
+ public void setTileCachePath(MapUrlTile view, @Nullable String value) {
112
+ view.setTileCachePath(value);
113
+ }
114
+
115
+ @Override
116
+ public void setTileSize(MapUrlTile view, int value) {
117
+ view.setTileSize(value);
118
+ }
119
+
120
+ @Override
121
+ public void setUrlTemplate(MapUrlTile view, @Nullable String value) {
122
+ view.setUrlTemplate(value);
123
+ }
124
+ }
@@ -17,6 +17,7 @@ import com.rnmaps.fabric.NativeAirMapsModule;
17
17
  import com.rnmaps.fabric.OverlayManager;
18
18
  import com.rnmaps.fabric.PolygonManager;
19
19
  import com.rnmaps.fabric.PolylineManager;
20
+ import com.rnmaps.fabric.UrlTileManager;
20
21
 
21
22
  import java.util.HashMap;
22
23
  import java.util.List;
@@ -26,7 +27,14 @@ public class MapAirModulePackage extends TurboReactPackage {
26
27
 
27
28
  @Override
28
29
  public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
29
- return List.of(new MapViewManager(reactContext), new MarkerManager(reactContext), new CalloutManager(reactContext), new PolygonManager(reactContext), new PolylineManager(reactContext), new CircleManager(reactContext), new OverlayManager(reactContext));
30
+ return List.of(new MapViewManager(reactContext),
31
+ new MarkerManager(reactContext),
32
+ new CalloutManager(reactContext),
33
+ new PolygonManager(reactContext),
34
+ new PolylineManager(reactContext),
35
+ new CircleManager(reactContext),
36
+ new OverlayManager(reactContext),
37
+ new UrlTileManager(reactContext));
30
38
  }
31
39
 
32
40
 
@@ -53,8 +61,11 @@ public class MapAirModulePackage extends TurboReactPackage {
53
61
  if (MapViewManager.REACT_CLASS.equals(name)) {
54
62
  return new MapViewManager(reactContext);
55
63
  }
64
+ if (UrlTileManager.REACT_CLASS.equals(name)) {
65
+ return new UrlTileManager(reactContext);
66
+ }
56
67
  if (NativeAirMapsModuleSpec.NAME.equals(name)) {
57
- return (NativeModule) new NativeAirMapsModule(reactContext);
68
+ return new NativeAirMapsModule(reactContext);
58
69
  } else {
59
70
  return null;
60
71
  }
@@ -176,7 +176,7 @@ public class MapUrlTile extends MapFeature {
176
176
  if (tileProvider != null) {
177
177
  tileProvider.setCustomMode();
178
178
  }
179
- }
179
+ }
180
180
 
181
181
  protected TileOverlayOptions createTileOverlayOptions() {
182
182
  Log.d("urlTile ", "creating TileProvider");
@@ -13,10 +13,6 @@ public class MapUrlTileManager extends ViewGroupManager<MapUrlTile> {
13
13
 
14
14
  public MapUrlTileManager(ReactApplicationContext reactContext) {
15
15
  super();
16
- DisplayMetrics metrics = new DisplayMetrics();
17
- ((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
18
- .getDefaultDisplay()
19
- .getRealMetrics(metrics);
20
16
  }
21
17
 
22
18
  @Override
@@ -24,6 +24,7 @@ registry->add(concreteComponentDescriptorProvider<RNMapsMapViewComponentDescript
24
24
  registry->add(concreteComponentDescriptorProvider<RNMapsMarkerComponentDescriptor>());
25
25
  registry->add(concreteComponentDescriptorProvider<RNMapsOverlayComponentDescriptor>());
26
26
  registry->add(concreteComponentDescriptorProvider<RNMapsPolylineComponentDescriptor>());
27
+ registry->add(concreteComponentDescriptorProvider<RNMapsUrlTileComponentDescriptor>());
27
28
  }
28
29
 
29
30
  } // namespace facebook::react
@@ -24,6 +24,7 @@ using RNMapsMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMapsMapVi
24
24
  using RNMapsMarkerComponentDescriptor = ConcreteComponentDescriptor<RNMapsMarkerShadowNode>;
25
25
  using RNMapsOverlayComponentDescriptor = ConcreteComponentDescriptor<RNMapsOverlayShadowNode>;
26
26
  using RNMapsPolylineComponentDescriptor = ConcreteComponentDescriptor<RNMapsPolylineShadowNode>;
27
+ using RNMapsUrlTileComponentDescriptor = ConcreteComponentDescriptor<RNMapsUrlTileShadowNode>;
27
28
 
28
29
  void RNMapsSpecs_registerComponentDescriptorsFromCodegen(
29
30
  std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
@@ -974,4 +974,5 @@ $payload.setProperty(runtime, "id", $event.id);
974
974
  });
975
975
  }
976
976
 
977
+
977
978
  } // namespace facebook::react
@@ -842,5 +842,12 @@ class RNMapsPolylineEventEmitter : public ViewEventEmitter {
842
842
  OnPressPosition position;
843
843
  };
844
844
  void onPress(OnPress value) const;
845
+ };
846
+ class RNMapsUrlTileEventEmitter : public ViewEventEmitter {
847
+ public:
848
+ using ViewEventEmitter::ViewEventEmitter;
849
+
850
+
851
+
845
852
  };
846
853
  } // namespace facebook::react
@@ -191,5 +191,22 @@ RNMapsPolylineProps::RNMapsPolylineProps(
191
191
  strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {0.0})),
192
192
  tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {false}))
193
193
  {}
194
+ RNMapsUrlTileProps::RNMapsUrlTileProps(
195
+ const PropsParserContext &context,
196
+ const RNMapsUrlTileProps &sourceProps,
197
+ const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
198
+
199
+ doubleTileSize(convertRawProp(context, rawProps, "doubleTileSize", sourceProps.doubleTileSize, {false})),
200
+ flipY(convertRawProp(context, rawProps, "flipY", sourceProps.flipY, {false})),
201
+ maximumNativeZ(convertRawProp(context, rawProps, "maximumNativeZ", sourceProps.maximumNativeZ, {0})),
202
+ maximumZ(convertRawProp(context, rawProps, "maximumZ", sourceProps.maximumZ, {0})),
203
+ minimumZ(convertRawProp(context, rawProps, "minimumZ", sourceProps.minimumZ, {0})),
204
+ offlineMode(convertRawProp(context, rawProps, "offlineMode", sourceProps.offlineMode, {false})),
205
+ shouldReplaceMapContent(convertRawProp(context, rawProps, "shouldReplaceMapContent", sourceProps.shouldReplaceMapContent, {false})),
206
+ tileCacheMaxAge(convertRawProp(context, rawProps, "tileCacheMaxAge", sourceProps.tileCacheMaxAge, {0})),
207
+ tileCachePath(convertRawProp(context, rawProps, "tileCachePath", sourceProps.tileCachePath, {})),
208
+ tileSize(convertRawProp(context, rawProps, "tileSize", sourceProps.tileSize, {0})),
209
+ urlTemplate(convertRawProp(context, rawProps, "urlTemplate", sourceProps.urlTemplate, {}))
210
+ {}
194
211
 
195
212
  } // namespace facebook::react
@@ -1222,4 +1222,24 @@ class RNMapsPolylineProps final : public ViewProps {
1222
1222
  bool tappable{false};
1223
1223
  };
1224
1224
 
1225
+ class RNMapsUrlTileProps final : public ViewProps {
1226
+ public:
1227
+ RNMapsUrlTileProps() = default;
1228
+ RNMapsUrlTileProps(const PropsParserContext& context, const RNMapsUrlTileProps &sourceProps, const RawProps &rawProps);
1229
+
1230
+ #pragma mark - Props
1231
+
1232
+ bool doubleTileSize{false};
1233
+ bool flipY{false};
1234
+ int maximumNativeZ{0};
1235
+ int maximumZ{0};
1236
+ int minimumZ{0};
1237
+ bool offlineMode{false};
1238
+ bool shouldReplaceMapContent{false};
1239
+ int tileCacheMaxAge{0};
1240
+ std::string tileCachePath{};
1241
+ int tileSize{0};
1242
+ std::string urlTemplate{};
1243
+ };
1244
+
1225
1245
  } // namespace facebook::react
@@ -20,5 +20,6 @@ extern const char RNMapsMapViewComponentName[] = "RNMapsMapView";
20
20
  extern const char RNMapsMarkerComponentName[] = "RNMapsMarker";
21
21
  extern const char RNMapsOverlayComponentName[] = "RNMapsOverlay";
22
22
  extern const char RNMapsPolylineComponentName[] = "RNMapsPolyline";
23
+ extern const char RNMapsUrlTileComponentName[] = "RNMapsUrlTile";
23
24
 
24
25
  } // namespace facebook::react
@@ -106,4 +106,15 @@ using RNMapsPolylineShadowNode = ConcreteViewShadowNode<
106
106
  RNMapsPolylineEventEmitter,
107
107
  RNMapsPolylineState>;
108
108
 
109
+ JSI_EXPORT extern const char RNMapsUrlTileComponentName[];
110
+
111
+ /*
112
+ * `ShadowNode` for <RNMapsUrlTile> component.
113
+ */
114
+ using RNMapsUrlTileShadowNode = ConcreteViewShadowNode<
115
+ RNMapsUrlTileComponentName,
116
+ RNMapsUrlTileProps,
117
+ RNMapsUrlTileEventEmitter,
118
+ RNMapsUrlTileState>;
119
+
109
120
  } // namespace facebook::react
@@ -110,4 +110,16 @@ public:
110
110
  #endif
111
111
  };
112
112
 
113
+ class RNMapsUrlTileState {
114
+ public:
115
+ RNMapsUrlTileState() = default;
116
+
117
+ #ifdef ANDROID
118
+ RNMapsUrlTileState(RNMapsUrlTileState const &previousState, folly::dynamic data){};
119
+ folly::dynamic getDynamic() const {
120
+ return {};
121
+ };
122
+ #endif
123
+ };
124
+
113
125
  } // namespace facebook::react
@@ -626,6 +626,9 @@ using namespace facebook::react;
626
626
  case RNMapsGoogleMapViewMapType::Hybrid:
627
627
  _view.mapType = kGMSTypeHybrid;
628
628
  break;
629
+ case RNMapsGoogleMapViewMapType::None:
630
+ _view.mapType = kGMSTypeNone;
631
+ break;
629
632
  default:
630
633
  _view.mapType = kGMSTypeNormal;
631
634
  break;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "main": "src/index.ts",
6
6
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
7
7
  "homepage": "https://github.com/react-native-maps/react-native-maps#readme",
8
- "version": "1.21.0-alpha.135",
8
+ "version": "1.21.0-alpha.137",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",
@@ -22,6 +22,7 @@ import {MapWMSTile} from './MapWMSTile';
22
22
  import {Commands} from './MapViewNativeComponent';
23
23
  import GooglePolygon from './specs/NativeComponentGooglePolygon';
24
24
  import FabricMarker from './specs/NativeComponentMarker';
25
+ import FabricUrlTile from './specs/NativeComponentUrlTile';
25
26
  import FabricCallout from './specs/NativeComponentCallout';
26
27
  import FabricPolyline from './specs/NativeComponentPolyline';
27
28
  import FabricCircle from './specs/NativeComponentCircle';
@@ -104,6 +105,9 @@ export default function decorateMapComponent<Type extends Component>(
104
105
  } else if (componentName === 'Overlay') {
105
106
  // @ts-ignore
106
107
  return FabricOverlay;
108
+ } else if (componentName === 'UrlTile') {
109
+ // @ts-ignore
110
+ return FabricUrlTile;
107
111
  }
108
112
  }
109
113
  const key = provider || 'default';
@@ -0,0 +1,128 @@
1
+ import type {HostComponent, ViewProps} from 'react-native';
2
+
3
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
4
+ import {Int32} from 'react-native/Libraries/Types/CodegenTypes';
5
+
6
+ export interface UrlTileFabricNativeProps extends ViewProps {
7
+ /**
8
+ * Doubles tile size from 256 to 512 utilising higher zoom levels
9
+ * i.e loading 4 higher zoom level tiles and combining them for one high-resolution tile.
10
+ * iOS does this automatically, even if it is not desirable always.
11
+ * NB! using this makes text labels smaller than in the original map style.
12
+ *
13
+ * @platform iOS: Not supported
14
+ * @platform Android: Supported
15
+ */
16
+ doubleTileSize?: boolean;
17
+
18
+ /**
19
+ * Allow tiles using the TMS coordinate system (origin bottom left) to be used,
20
+ * and displayed at their correct coordinates.
21
+ *
22
+ * @platform iOS: Supported
23
+ * @platform Android: Supported
24
+ */
25
+ flipY?: boolean;
26
+
27
+ /**
28
+ * The maximum native zoom level for this tile overlay i.e. the highest zoom level that the tile server provides.
29
+ * Tiles are auto-scaled for higher zoom levels.
30
+ *
31
+ * @platform iOS: Apple Maps only
32
+ * @platform Android: Supported
33
+ */
34
+ maximumNativeZ?: Int32;
35
+
36
+ /**
37
+ * The maximum zoom level for this tile overlay.
38
+ *
39
+ * @platform iOS: Supported
40
+ * @platform Android: Supported
41
+ */
42
+ maximumZ?: Int32;
43
+
44
+ /**
45
+ * The minimum zoom level for this tile overlay.
46
+ *
47
+ * @platform iOS: Supported
48
+ * @platform Android: Supported
49
+ */
50
+ minimumZ?: Int32;
51
+
52
+ /**
53
+ * In offline-mode tiles are not fetched from the tile servers, rather only tiles stored in the cache directory are used.
54
+ * Furthermore, automated tile scaling is activated: if tile at a desired zoom level is not found from the cache directory,
55
+ * then lower zoom level tile is used (up to 4 levels lower) and scaled.
56
+ *
57
+ * @default false
58
+ * @platform iOS: Apple Maps only
59
+ * @platform Android: Supported
60
+ */
61
+ offlineMode?: boolean;
62
+
63
+ /**
64
+ * Corresponds to MKTileOverlay canReplaceMapContent i.e. if true then underlying iOS basemap is not shown.
65
+ *
66
+ * @default false
67
+ * @platform iOS: Apple Maps only
68
+ * @platform Android: Not supported
69
+ */
70
+ shouldReplaceMapContent?: boolean;
71
+
72
+ /**
73
+ * Defines maximum age in seconds for a cached tile before it's refreshed.
74
+ *
75
+ * NB! Refresh logic is "serve-stale-while-refresh"
76
+ * i.e. to ensure map availability a stale (over max age) tile is served
77
+ * while a tile refresh process is started in the background.
78
+ *
79
+ * @platform iOS: Apple Maps only
80
+ * @platform Android: Supported
81
+ */
82
+ tileCacheMaxAge?: Int32;
83
+
84
+ /**
85
+ * Enable caching of tiles in the specified directory.
86
+ * Directory can be specified either as a normal path or in URL format (`file://`).
87
+ *
88
+ * Tiles are stored in tileCachePath directory as `/{z}/{x}/{y}` i.e. in sub-directories 2-levels deep,
89
+ * filename is tile y-coordinate without any filetype-extension.
90
+ *
91
+ * NB! All cache management needs to be implemented by client e.g. deleting tiles to manage use of storage space etc.
92
+ *
93
+ * @platform iOS: Apple Maps only
94
+ * @platform Android: Supported
95
+ */
96
+ tileCachePath?: string;
97
+
98
+ /**
99
+ * Tile size, default size is 256 (for tiles of 256 _ 256 pixels).
100
+ * High-res (aka 'retina') tiles are 512 (tiles of 512 _ 512 pixels)
101
+ *
102
+ * @platform iOS: Apple Maps only
103
+ * @platform Android: Supported
104
+ */
105
+ tileSize?: Int32;
106
+
107
+ /**
108
+ * The url template of the map tileserver.
109
+ * (URLTile) The patterns {x} {y} {z} will be replaced at runtime.
110
+ * For example, http://c.tile.openstreetmap.org/{z}/{x}/{y}.png.
111
+ *
112
+ * It is also possible to refer to tiles in local filesystem with file:///top-level-directory/sub-directory/{z}/{x}/{y}.png URL-format.
113
+ * (WMSTile) The patterns {minX} {maxX} {minY} {maxY} {width} {height} will be replaced at runtime according to EPSG:900913 specification bounding box.
114
+ * For example, https://demo.geo-solutions.it/geoserver/tiger/wms?service=WMS&version=1.1.0&request=GetMap&layers=tiger:poi&styles=&bbox={minX},{minY},{maxX},{maxY}&width={width}&height={height}&srs=EPSG:900913&format=image/png&transparent=true&format_options=dpi:213.
115
+ *
116
+ * @platform iOS: Supported
117
+ * @platform Android: Supported
118
+ */
119
+
120
+ urlTemplate: string;
121
+ }
122
+
123
+ export default codegenNativeComponent<UrlTileFabricNativeProps>(
124
+ 'RNMapsUrlTile',
125
+ {
126
+ excludedPlatforms: ['iOS'],
127
+ },
128
+ ) as HostComponent<UrlTileFabricNativeProps>;