@rnmapbox/maps 10.0.0-beta.30 → 10.0.0-beta.33

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,6 @@
1
+ import React from 'react';
2
+ import type { Map } from 'mapbox-gl';
3
+
4
+ const MapContext = React.createContext<{ map?: Map }>({});
5
+
6
+ export default MapContext;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+
3
+ import MapContext from '../MapContext';
4
+
5
+ class Camera extends React.Component<{
6
+ centerCoordinate: [number, number] | null;
7
+ }> {
8
+ context!: React.ContextType<typeof MapContext>;
9
+
10
+ static contextType = MapContext;
11
+ static UserTrackingModes = [];
12
+
13
+ componentDidMount() {
14
+ const { map } = this.context;
15
+ const { centerCoordinate } = this.props;
16
+ if (map && centerCoordinate) {
17
+ map.flyTo({ center: centerCoordinate });
18
+ }
19
+ }
20
+
21
+ fitBounds(
22
+ northEastCoordinates: [number, number],
23
+ southWestCoordinates: [number, number],
24
+ padding = 0,
25
+ animationDuration = 0.0,
26
+ ) {
27
+ const { map } = this.context;
28
+ if (map) {
29
+ map.fitBounds([northEastCoordinates, southWestCoordinates]);
30
+ }
31
+ }
32
+
33
+ render() {
34
+ return <></>;
35
+ }
36
+ }
37
+
38
+ export { Camera };
39
+ export default Camera;
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import mapboxgl from 'mapbox-gl';
3
+
4
+ import MapContext from '../MapContext';
5
+
6
+ /**
7
+ * MapView backed by Mapbox GL KS
8
+ */
9
+ class MapView extends React.Component<
10
+ { styleURL: string; children: JSX.Element },
11
+ { map?: object | null }
12
+ > {
13
+ state = { map: null };
14
+ mapContainer: HTMLElement | null = null;
15
+ map: object | null = null;
16
+
17
+ componentDidMount() {
18
+ const { styleURL } = this.props;
19
+ if (!this.mapContainer) {
20
+ console.error('MapView - mapContainer should is null');
21
+ return;
22
+ }
23
+ const map = new mapboxgl.Map({
24
+ container: this.mapContainer,
25
+ style: styleURL || 'mapbox://styles/mapbox/streets-v11',
26
+ });
27
+ this.map = map;
28
+ this.setState({ map });
29
+ }
30
+
31
+ render() {
32
+ const { children } = this.props;
33
+ const { map } = this.state;
34
+ return (
35
+ <div
36
+ style={{ width: '100%', height: '100%' }}
37
+ ref={(el) => (this.mapContainer = el)}
38
+ >
39
+ {map && (
40
+ <div style={{ position: 'absolute' }}>
41
+ <MapContext.Provider value={{ map }}>
42
+ {children}
43
+ </MapContext.Provider>
44
+ </div>
45
+ )}
46
+ </div>
47
+ );
48
+ }
49
+ }
50
+
51
+ export default MapView;
package/package.json CHANGED
@@ -1,13 +1,14 @@
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.30",
4
+ "version": "10.0.0-beta.33",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "author": "React Native Mapbox Team",
9
9
  "main": "./javascript/index.js",
10
10
  "browser": "./javascript/index.web.js",
11
+ "react-native": "./javascript/index.js",
11
12
  "keywords": [
12
13
  "gl",
13
14
  "ios",
@@ -28,10 +29,11 @@
28
29
  "unittest:single": "jest --testNamePattern",
29
30
  "lint": "eslint .",
30
31
  "lint:fix": "eslint . --fix",
31
- "type:check": "yarn tsc --noEmit",
32
+ "type:check": "tsc --noEmit",
32
33
  "test:plugin": "expo-module test plugin",
33
34
  "build:plugin": "tsc --build plugin",
34
- "lint:plugin": "eslint plugin/src/*"
35
+ "lint:plugin": "eslint plugin/src/*",
36
+ "prepare": "husky install"
35
37
  },
36
38
  "peerDependencies": {
37
39
  "prop-types": ">=15.5.8",
@@ -64,6 +66,7 @@
64
66
  "@react-native-community/eslint-config": "^3.0.1",
65
67
  "@sinonjs/fake-timers": "^8.0.1",
66
68
  "@testing-library/react-native": "^8.0.0",
69
+ "@types/mapbox-gl": "^2.7.5",
67
70
  "@types/react-native": ">=0.59.9",
68
71
  "@typescript-eslint/eslint-plugin": "^5.20.0",
69
72
  "@typescript-eslint/parser": "^5.20.0",
@@ -77,7 +80,7 @@
77
80
  "eslint-plugin-fp": "^2.3.0",
78
81
  "eslint-plugin-import": "2.25.3",
79
82
  "expo-module-scripts": "^2.0.0",
80
- "husky": "^7.0.4",
83
+ "husky": "^8.0.1",
81
84
  "jest": "27.5.1",
82
85
  "jest-cli": "27.5.1",
83
86
  "lint-staged": "^12.1.2",
@@ -88,7 +91,8 @@
88
91
  "react-docgen": "6.0.0-alpha.3",
89
92
  "react-native": "0.67.0",
90
93
  "react-test-renderer": "17.0.2",
91
- "typescript": "^4.4.3"
94
+ "typescript": "^4.4.3",
95
+ "mapbox-gl": "^ 2.9.0"
92
96
  },
93
97
  "jest": {
94
98
  "preset": "react-native",
@@ -105,11 +109,6 @@
105
109
  "fixtures"
106
110
  ]
107
111
  },
108
- "husky": {
109
- "hooks": {
110
- "pre-commit": "lint-staged && npm run generate"
111
- }
112
- },
113
112
  "lint-staged": {
114
113
  "*.{js,jsx,ts,tsx}": "eslint --fix"
115
114
  }
@@ -464,8 +464,8 @@ async function generate() {
464
464
  only: 'v10',
465
465
  },
466
466
  {
467
- input: path.join(TMPL_PATH, 'styleMap.js.ejs'),
468
- output: path.join(JS_OUTPUT_PATH, 'styleMap.js'),
467
+ input: path.join(TMPL_PATH, 'styleMap.ts.ejs'),
468
+ output: path.join(JS_OUTPUT_PATH, 'styleMap.ts'),
469
469
  },
470
470
  ];
471
471
  const outputPaths = templateMappings.map((m) => m.output);
@@ -6,7 +6,7 @@
6
6
  // THIS FILE IS AUTOGENERATED
7
7
 
8
8
  import PropTypes from 'prop-types';
9
- import { IS_ANDROID } from './index';
9
+ import { isAndroid } from './index';
10
10
 
11
11
  export const StyleTypes = {
12
12
  Constant: 'constant',
@@ -18,8 +18,8 @@ export const StyleTypes = {
18
18
  Enum: 'enum',
19
19
  };
20
20
 
21
- export function getStyleType(styleProp) {
22
- if (!IS_ANDROID && styleExtras[styleProp]) {
21
+ export function getStyleType(styleProp: keyof typeof styleExtras) {
22
+ if (!isAndroid() && styleExtras[styleProp]) {
23
23
  return styleExtras[styleProp].iosType;
24
24
  }
25
25
 
@@ -62,7 +62,7 @@ export const <%- pascelCase(layer.name) _%>LayerStyleProp = PropTypes.shape({
62
62
  const styleMap = {
63
63
  <%_ for (let layer of layers) { _%>
64
64
  <%_ for (let prop of layer.properties) { _%>
65
- <%_ if (prop.name !== 'visibility') { _%>
65
+ <%_ if (!['color', 'colorTransition', 'visibility'].includes(prop.name)) { _%>
66
66
  <%= prop.name %>: <%- jsStyleType(prop) %>,
67
67
  <%_ if (prop.transition) { _%>
68
68
  <%= prop.name %>Transition: StyleTypes.Transition,
@@ -71,6 +71,9 @@ const styleMap = {
71
71
  <%_ } _%>
72
72
 
73
73
  <%_ } _%>
74
+
75
+ color: StyleTypes.Color,
76
+ colorTransition: StyleTypes.Transition,
74
77
  visibility: StyleTypes.Constant,
75
78
  };
76
79
 
@@ -1,75 +0,0 @@
1
- ---
2
- name: Bug
3
- about: This template should be used for reporting bugs and defects.
4
- title: ''
5
- labels: 'bug :beetle:'
6
- assignees: ''
7
-
8
- ---
9
-
10
-
11
- ## Environment
12
-
13
- - Mapbox (GL) implementation: [e.g. v10, MapLibre, MapboxGL]
14
- - Mapbox (GL) version: [e.g. 6.3.0]
15
- - @rnmapbox/maps Version [e.g. #main]
16
- - Platform: [e.g. Android, iOS]
17
- - React Native Version [e.g. 0.59]
18
- - Platform OS: [e.g. Android 9, iOS 10]
19
- - Device: [e.g. iPhone6]
20
- - Emulator/ Simulator: [yes/ no]
21
- - Dev OS: [e.g. OSX 11.0.1, Win10]
22
-
23
- ## Standalone component to reproduce
24
-
25
- <!--- Use [our BugReportTemplate](https://github.com/rnmapbox/maps/blob/main/example/src/examples/BugReportExample.js) screens as a starting point. --->
26
- <!--- Component should be self contained - no extra libraries, external data, no parameters --->
27
- <!--- Do not include setAccessToken or access token istelf. ---->
28
-
29
-
30
- ```js
31
- import React from 'react';
32
- import {
33
- MapView,
34
- ShapeSource,
35
- LineLayer,
36
- Camera,
37
- } from '@rnmapbox/maps';
38
-
39
- const aLine = {
40
- type: 'LineString',
41
- coordinates: [
42
- [-74.00597, 40.71427],
43
- [-74.00697, 40.71527],
44
- ],
45
- };
46
-
47
- class BugReportExample extends React.Component {
48
- render() {
49
- return (
50
- <MapView style={{flex: 1}}>
51
- <Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
52
- <ShapeSource id="idStreetLayer" shape={aLine}>
53
- <LineLayer id="idStreetLayer" />
54
- </ShapeSource>
55
- </MapView>
56
- );
57
- }
58
- }
59
- ```
60
-
61
- ## Observed behavior and steps to reproduce
62
-
63
- <!--- Please include as much evidence as possible (traces, videos, screenshots etc.) --->
64
-
65
- ## Expected behavior
66
-
67
- <!--- Please include the expected behavior and any resources supporting this expected behavior. --->
68
-
69
- ## Notes / preliminary analysis
70
-
71
- <!--- include your initial analysis, if available --->
72
-
73
- ## Additional links and references
74
-
75
- <!--- Links to traces, videos et --->
@@ -1,5 +0,0 @@
1
- declare module 'react-native/Libraries/Image/resolveAssetSource' {
2
- export default function resolveAssetSource(x: number): {
3
- [key: string]: string;
4
- };
5
- }
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
-
3
- const MapContext = React.createContext({});
4
-
5
- export default MapContext;