react-native-maps 0.31.1 → 1.0.0-beta.1

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.
Files changed (68) hide show
  1. package/README.md +1 -5
  2. package/android/src/main/AndroidManifest.xml +0 -3
  3. package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTile.java +11 -4
  4. package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTileManager.java +5 -1
  5. package/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java +2 -41
  6. package/android/src/main/java/com/airbnb/android/react/maps/AirMapTileProvider.java +5 -5
  7. package/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +0 -32
  8. package/ios/AirGoogleMaps/AIRGoogleMap.m +37 -31
  9. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +0 -95
  10. package/ios/AirMaps/AIRMap.m +0 -7
  11. package/ios/AirMaps/AIRMapManager.m +0 -105
  12. package/lib/AnimatedRegion.d.ts +19 -0
  13. package/lib/AnimatedRegion.js +134 -0
  14. package/lib/Geojson.d.ts +166 -0
  15. package/lib/Geojson.js +165 -0
  16. package/lib/MapCallout.d.ts +40 -0
  17. package/lib/MapCallout.js +51 -0
  18. package/lib/MapCalloutSubview.d.ts +34 -0
  19. package/lib/MapCalloutSubview.js +48 -0
  20. package/lib/MapCircle.d.ts +117 -0
  21. package/lib/MapCircle.js +53 -0
  22. package/lib/MapHeatmap.d.ts +77 -0
  23. package/lib/MapHeatmap.js +59 -0
  24. package/lib/MapLocalTile.d.ts +35 -0
  25. package/lib/MapLocalTile.js +44 -0
  26. package/lib/MapMarker.d.ts +289 -0
  27. package/lib/MapMarker.js +113 -0
  28. package/lib/MapOverlay.d.ts +86 -0
  29. package/lib/MapOverlay.js +63 -0
  30. package/lib/MapPolygon.d.ts +156 -0
  31. package/lib/MapPolygon.js +74 -0
  32. package/lib/MapPolyline.d.ts +156 -0
  33. package/lib/MapPolyline.js +53 -0
  34. package/lib/MapUrlTile.d.ts +134 -0
  35. package/lib/MapUrlTile.js +44 -0
  36. package/lib/MapView.d.ts +825 -0
  37. package/lib/MapView.js +418 -0
  38. package/{src/MapView.web.js → lib/MapView.web.d.ts} +0 -0
  39. package/lib/MapView.web.js +9 -0
  40. package/lib/MapWMSTile.d.ts +116 -0
  41. package/lib/MapWMSTile.js +44 -0
  42. package/lib/ProviderConstants.d.ts +2 -0
  43. package/lib/ProviderConstants.js +5 -0
  44. package/lib/decorateMapComponent.d.ts +35 -0
  45. package/lib/decorateMapComponent.js +80 -0
  46. package/{src/index.js → lib/index.d.ts} +5 -16
  47. package/lib/index.js +66 -0
  48. package/lib/sharedTypes.d.ts +82 -0
  49. package/lib/sharedTypes.js +2 -0
  50. package/package.json +18 -27
  51. package/react-native-google-maps.podspec +1 -1
  52. package/index.d.ts +0 -637
  53. package/src/AnimatedRegion.js +0 -164
  54. package/src/Geojson.js +0 -334
  55. package/src/MapCallout.js +0 -51
  56. package/src/MapCalloutSubview.js +0 -44
  57. package/src/MapCircle.js +0 -150
  58. package/src/MapHeatmap.js +0 -99
  59. package/src/MapLocalTile.js +0 -52
  60. package/src/MapMarker.js +0 -377
  61. package/src/MapOverlay.js +0 -86
  62. package/src/MapPolygon.js +0 -202
  63. package/src/MapPolyline.js +0 -168
  64. package/src/MapUrlTile.js +0 -131
  65. package/src/MapView.js +0 -1160
  66. package/src/MapWMSTile.js +0 -122
  67. package/src/ProviderConstants.js +0 -2
  68. package/src/decorateMapComponent.js +0 -112
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_native_1 = require("react-native");
4
+ const AnimatedWithChildren = Object.getPrototypeOf(react_native_1.Animated.ValueXY);
5
+ if (__DEV__) {
6
+ if (AnimatedWithChildren.name !== 'AnimatedWithChildren') {
7
+ console.error('AnimatedRegion could not obtain AnimatedWithChildren base class');
8
+ }
9
+ }
10
+ const configTypes = [
11
+ 'latitude',
12
+ 'longitude',
13
+ 'latitudeDelta',
14
+ 'longitudeDelta',
15
+ ];
16
+ const defaultValues = {
17
+ // probably want to come up with better defaults
18
+ latitude: 0,
19
+ longitude: 0,
20
+ latitudeDelta: 0,
21
+ longitudeDelta: 0,
22
+ };
23
+ let _uniqueId = 1;
24
+ const getAnimatedValue = (valueIn, fallback) => {
25
+ if (valueIn instanceof react_native_1.Animated.Value) {
26
+ return valueIn;
27
+ }
28
+ else if (typeof valueIn === 'number') {
29
+ return new react_native_1.Animated.Value(valueIn);
30
+ }
31
+ return new react_native_1.Animated.Value(fallback);
32
+ };
33
+ class AnimatedMapRegion extends AnimatedWithChildren {
34
+ constructor(valueIn = {}) {
35
+ super();
36
+ this.latitude = getAnimatedValue(valueIn.latitude, defaultValues.latitude);
37
+ this.longitude = getAnimatedValue(valueIn.longitude, defaultValues.longitude);
38
+ this.latitudeDelta = getAnimatedValue(valueIn.latitudeDelta, defaultValues.latitudeDelta);
39
+ this.longitudeDelta = getAnimatedValue(valueIn.longitudeDelta, defaultValues.longitudeDelta);
40
+ this._regionListeners = {};
41
+ }
42
+ setValue(value) {
43
+ this.latitude._value = value.latitude;
44
+ this.longitude._value = value.longitude;
45
+ this.latitudeDelta._value = value.latitudeDelta;
46
+ this.longitudeDelta._value = value.longitudeDelta;
47
+ }
48
+ setOffset(offset) {
49
+ this.latitude.setOffset(offset.latitude);
50
+ this.longitude.setOffset(offset.longitude);
51
+ this.latitudeDelta.setOffset(offset.latitudeDelta);
52
+ this.longitudeDelta.setOffset(offset.longitudeDelta);
53
+ }
54
+ flattenOffset() {
55
+ this.latitude.flattenOffset();
56
+ this.longitude.flattenOffset();
57
+ this.latitudeDelta.flattenOffset();
58
+ this.longitudeDelta.flattenOffset();
59
+ }
60
+ __getValue() {
61
+ return {
62
+ latitude: this.latitude.__getValue(),
63
+ longitude: this.longitude.__getValue(),
64
+ latitudeDelta: this.latitudeDelta.__getValue(),
65
+ longitudeDelta: this.longitudeDelta.__getValue(),
66
+ };
67
+ }
68
+ __attach() {
69
+ this.latitude.__addChild(this);
70
+ this.longitude.__addChild(this);
71
+ this.latitudeDelta.__addChild(this);
72
+ this.longitudeDelta.__addChild(this);
73
+ }
74
+ __detach() {
75
+ this.latitude.__removeChild(this);
76
+ this.longitude.__removeChild(this);
77
+ this.latitudeDelta.__removeChild(this);
78
+ this.longitudeDelta.__removeChild(this);
79
+ }
80
+ stopAnimation(callback) {
81
+ this.latitude.stopAnimation();
82
+ this.longitude.stopAnimation();
83
+ this.latitudeDelta.stopAnimation();
84
+ this.longitudeDelta.stopAnimation();
85
+ callback && callback(this.__getValue());
86
+ }
87
+ addListener(callback) {
88
+ const id = String(_uniqueId++);
89
+ const jointCallback = () => /*{value}*/ callback(this.__getValue());
90
+ this._regionListeners[id] = {
91
+ latitude: this.latitude.addListener(jointCallback),
92
+ longitude: this.longitude.addListener(jointCallback),
93
+ latitudeDelta: this.latitudeDelta.addListener(jointCallback),
94
+ longitudeDelta: this.longitudeDelta.addListener(jointCallback),
95
+ };
96
+ return id;
97
+ }
98
+ removeListener(id) {
99
+ this.latitude.removeListener(this._regionListeners[id].latitude);
100
+ this.longitude.removeListener(this._regionListeners[id].longitude);
101
+ this.latitudeDelta.removeListener(this._regionListeners[id].latitudeDelta);
102
+ this.longitudeDelta.removeListener(this._regionListeners[id].longitudeDelta);
103
+ delete this._regionListeners[id];
104
+ }
105
+ spring(config) {
106
+ const animations = [];
107
+ for (const type of configTypes) {
108
+ if (config.hasOwnProperty(type)) {
109
+ animations.push(react_native_1.Animated.spring(this[type], {
110
+ ...config,
111
+ toValue: config[type],
112
+ // may help to eliminate some dev warnings and perf issues
113
+ useNativeDriver: !!config?.useNativeDriver,
114
+ }));
115
+ }
116
+ }
117
+ return react_native_1.Animated.parallel(animations);
118
+ }
119
+ timing(config) {
120
+ const animations = [];
121
+ for (const type of configTypes) {
122
+ if (config.hasOwnProperty(type)) {
123
+ animations.push(react_native_1.Animated.timing(this[type], {
124
+ ...config,
125
+ toValue: config[type],
126
+ // may help to eliminate some dev warnings and perf issues
127
+ useNativeDriver: !!config?.useNativeDriver,
128
+ }));
129
+ }
130
+ }
131
+ return react_native_1.Animated.parallel(animations);
132
+ }
133
+ }
134
+ exports.default = AnimatedMapRegion;
@@ -0,0 +1,166 @@
1
+ /// <reference types="react" />
2
+ import { Feature, FeatureCollection, Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon } from 'geojson';
3
+ import { Props as MarkerProps } from './MapMarker';
4
+ import { Props as PolygonProps } from './MapPolygon';
5
+ import { Props as PolylineProps } from './MapPolyline';
6
+ import { LatLng } from './sharedTypes';
7
+ declare type Props = {
8
+ /**
9
+ * The pincolor used on markers
10
+ *
11
+ * @platform iOS: Supported
12
+ * @platform Android: Supported
13
+ */
14
+ color?: MarkerProps['pinColor'];
15
+ /**
16
+ * The fill color to use for the path.
17
+ *
18
+ * @platform iOS: Supported
19
+ * @platform Android: Supported
20
+ */
21
+ fillColor?: PolygonProps['fillColor'];
22
+ /**
23
+ * [Geojson](https://geojson.org/) description of object.
24
+ *
25
+ * @platform iOS: Supported
26
+ * @platform Android: Supported
27
+ */
28
+ geojson: FeatureCollection;
29
+ /**
30
+ * A custom image to be used as the marker's icon. Only local image resources are allowed to be
31
+ * used.
32
+ *
33
+ * @platform iOS: Supported
34
+ * @platform Android: Supported
35
+ */
36
+ image?: MarkerProps['image'];
37
+ /**
38
+ * The line cap style to apply to the open ends of the path.
39
+ * The default style is `round`.
40
+ *
41
+ * @platform iOS: Apple Maps only
42
+ * @platform Android: Supported
43
+ */
44
+ lineCap?: PolylineProps['lineCap'];
45
+ /**
46
+ * An array of numbers specifying the dash pattern to use for the path.
47
+ *
48
+ * The array contains one or more numbers that indicate the lengths (measured in points) of the
49
+ * line segments and gaps in the pattern. The values in the array alternate, starting with the
50
+ * first line segment length, followed by the first gap length, followed by the second line
51
+ * segment length, and so on.
52
+ *
53
+ * This property is set to `null` by default, which indicates no line dash pattern.
54
+ *
55
+ * @platform iOS: Supported
56
+ * @platform Android: Supported
57
+ */
58
+ lineDashPattern?: PolylineProps['lineDashPattern'];
59
+ /**
60
+ * The offset (in points) at which to start drawing the dash pattern.
61
+ *
62
+ * Use this property to start drawing a dashed line partway through a segment or gap. For
63
+ * example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the
64
+ * middle of the first gap.
65
+ *
66
+ * The default value of this property is 0.
67
+ *
68
+ * @platform iOS: Apple Maps only
69
+ * @platform Android: Not supported
70
+ */
71
+ lineDashPhase?: PolylineProps['lineDashPhase'];
72
+ /**
73
+ * The line join style to apply to corners of the path.
74
+ * The default style is `round`.
75
+ *
76
+ * @platform iOS: Apple Maps only
77
+ * @platform Android: Not supported
78
+ */
79
+ lineJoin?: PolylineProps['lineJoin'];
80
+ /**
81
+ * Component to render in place of the default marker when the overlay type is a `point`
82
+ *
83
+ * @platform iOS: Supported
84
+ * @platform Android: Supported
85
+ */
86
+ markerComponent?: MarkerProps['children'];
87
+ /**
88
+ * The limiting value that helps avoid spikes at junctions between connected line segments.
89
+ * The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style. If
90
+ * the ratio of the miter length—that is, the diagonal length of the miter join—to the line
91
+ * thickness exceeds the miter limit, the joint is converted to a bevel join. The default
92
+ * miter limit is 10, which results in the conversion of miters whose angle at the joint
93
+ * is less than 11 degrees.
94
+ *
95
+ * @platform iOS: Apple Maps only
96
+ * @platform Android: Not supported
97
+ */
98
+ miterLimit?: PolylineProps['miterLimit'];
99
+ /**
100
+ * Callback that is called when the user presses any of the overlays
101
+ */
102
+ onPress?: (event: OverlayPressEvent) => void;
103
+ /**
104
+ * The stroke color to use for the path.
105
+ *
106
+ * @platform — iOS: Supported
107
+ * @platform — Android: Supported
108
+ */
109
+ strokeColor?: PolygonProps['strokeColor'] | PolylineProps['strokeColor'];
110
+ /**
111
+ * The stroke width to use for the path.
112
+ *
113
+ * @platform — iOS: Supported
114
+ * @platform — Android: Supported
115
+ */
116
+ strokeWidth?: PolygonProps['strokeWidth'] | PolylineProps['strokeWidth'];
117
+ /**
118
+ * Make the `Polygon` or `Polyline` tappable
119
+ *
120
+ * @platform — iOS: Google Maps only
121
+ * @platform — Android: Supported
122
+ */
123
+ tappable?: PolygonProps['tappable'] | PolylineProps['tappable'];
124
+ /**
125
+ * The title of the marker. This is only used if the <Marker /> component has no children that
126
+ * are a `<Callout />`, in which case the default callout behavior will be used, which
127
+ * will show both the `title` and the `description`, if provided.
128
+ *
129
+ * @platform — iOS: Supported
130
+ * @platform — Android: Supported
131
+ */
132
+ title?: MarkerProps['title'];
133
+ /**
134
+ * The order in which this tile overlay is drawn with respect to other overlays. An overlay
135
+ * with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays
136
+ * with the same z-index is arbitrary. The default zIndex is 0.
137
+ *
138
+ * @platform iOS: Apple Maps: [Marker], Google Maps: [Marker, Polygon, Polyline]
139
+ * @platform Android: Supported
140
+ */
141
+ zIndex?: MarkerProps['zIndex'] | PolygonProps['zIndex'] | PolylineProps['zIndex'];
142
+ };
143
+ declare const Geojson: (props: Props) => JSX.Element;
144
+ export default Geojson;
145
+ declare type OverlayPressEvent = {
146
+ type: AnyPointOverlay['type'] | AnyLineStringOverlay['type'] | AnyPolygonOverlay['type'];
147
+ feature: AnyPointOverlay['feature'] | AnyLineStringOverlay['feature'] | AnyPolygonOverlay['feature'];
148
+ coordinates: AnyPointOverlay['coordinates'] | AnyLineStringOverlay['coordinates'] | AnyPolygonOverlay['coordinates'];
149
+ holes?: AnyPolygonOverlay['holes'];
150
+ };
151
+ declare type AnyPointOverlay = {
152
+ type: 'point';
153
+ feature: Feature<Point | MultiPoint>;
154
+ coordinates: LatLng;
155
+ };
156
+ declare type AnyLineStringOverlay = {
157
+ type: 'polyline';
158
+ feature: Feature<LineString | MultiLineString>;
159
+ coordinates: LatLng[];
160
+ };
161
+ declare type AnyPolygonOverlay = {
162
+ type: 'polygon';
163
+ feature: Feature<Polygon | MultiPolygon>;
164
+ coordinates: LatLng[];
165
+ holes?: LatLng[][];
166
+ };
package/lib/Geojson.js ADDED
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const React = __importStar(require("react"));
30
+ const MapMarker_1 = __importDefault(require("./MapMarker"));
31
+ const MapPolyline_1 = __importDefault(require("./MapPolyline"));
32
+ const MapPolygon_1 = __importDefault(require("./MapPolygon"));
33
+ const Geojson = (props) => {
34
+ const { geojson, strokeColor, fillColor, strokeWidth, color, title, image, zIndex, onPress, lineCap, lineJoin, tappable, miterLimit, lineDashPhase, lineDashPattern, markerComponent, } = props;
35
+ const pointOverlays = makePointOverlays(geojson.features);
36
+ const lineOverlays = makeLineOverlays(geojson.features);
37
+ const polygonOverlays = makePolygonOverlays(geojson.features);
38
+ return (<React.Fragment>
39
+ {pointOverlays.map((overlay, index) => {
40
+ const markerColor = getColor(color, overlay, 'marker-color');
41
+ return (<MapMarker_1.default key={index} coordinate={overlay.coordinates} image={image} title={title} pinColor={markerColor} zIndex={zIndex} onPress={() => onPress && onPress(overlay)}>
42
+ {markerComponent}
43
+ </MapMarker_1.default>);
44
+ })}
45
+ {lineOverlays.map((overlay, index) => {
46
+ const lineStrokeColor = getColor(strokeColor, overlay, 'stroke');
47
+ const lineStrokeWidth = getStrokeWidth(strokeWidth, overlay);
48
+ return (<MapPolyline_1.default key={index} coordinates={overlay.coordinates} strokeColor={lineStrokeColor} strokeWidth={lineStrokeWidth} lineDashPhase={lineDashPhase} lineDashPattern={lineDashPattern} lineCap={lineCap} lineJoin={lineJoin} miterLimit={miterLimit} zIndex={zIndex} tappable={tappable} onPress={() => onPress && onPress(overlay)}/>);
49
+ })}
50
+ {polygonOverlays.map((overlay, index) => {
51
+ const polygonFillColor = getColor(fillColor, overlay, 'fill');
52
+ const lineStrokeColor = getColor(strokeColor, overlay, 'stroke');
53
+ const lineStrokeWidth = getStrokeWidth(strokeWidth, overlay);
54
+ return (<MapPolygon_1.default key={index} coordinates={overlay.coordinates} holes={overlay.holes} strokeColor={lineStrokeColor} fillColor={polygonFillColor} strokeWidth={lineStrokeWidth} tappable={tappable} onPress={() => onPress && onPress(overlay)} zIndex={zIndex}/>);
55
+ })}
56
+ </React.Fragment>);
57
+ };
58
+ exports.default = Geojson;
59
+ const makePointOverlays = (features) => {
60
+ return features
61
+ .filter(isAnyPointFeature)
62
+ .map(feature => makeCoordinatesForAnyPoint(feature.geometry).map(coordinates => makeOverlayForAnyPoint(coordinates, feature)))
63
+ .reduce((prev, curr) => prev.concat(curr), [])
64
+ .map(overlay => ({ ...overlay, type: 'point' }));
65
+ };
66
+ const makeLineOverlays = (features) => {
67
+ return features
68
+ .filter(isAnyLineStringFeature)
69
+ .map(feature => makeCoordinatesForAnyLine(feature.geometry).map(coordinates => makeOverlayForAnyLine(coordinates, feature)))
70
+ .reduce((prev, curr) => prev.concat(curr), [])
71
+ .map(overlay => ({ ...overlay, type: 'polyline' }));
72
+ };
73
+ const makePolygonOverlays = (features) => {
74
+ const multipolygons = features
75
+ .filter(isMultiPolygonFeature)
76
+ .map(feature => makeCoordinatesForMultiPolygon(feature.geometry).map(coordinates => makeOverlayForAnyPolygon(coordinates, feature)))
77
+ .reduce((prev, curr) => prev.concat(curr), [])
78
+ .map(overlay => ({ ...overlay, type: 'polygon' }));
79
+ const polygons = features
80
+ .filter(isPolygonFeature)
81
+ .map(feature => makeOverlayForAnyPolygon(makeCoordinatesForPolygon(feature.geometry), feature))
82
+ .reduce((prev, curr) => prev.concat(curr), [])
83
+ .map(overlay => ({ ...overlay, type: 'polygon' }));
84
+ return polygons.concat(multipolygons);
85
+ };
86
+ const makeOverlayForAnyPoint = (coordinates, feature) => {
87
+ return { feature, coordinates };
88
+ };
89
+ const makeOverlayForAnyLine = (coordinates, feature) => {
90
+ return { feature, coordinates };
91
+ };
92
+ const makeOverlayForAnyPolygon = (coordinates, feature) => {
93
+ return {
94
+ feature,
95
+ coordinates: coordinates[0],
96
+ holes: coordinates.length > 1 ? coordinates.slice(1) : undefined,
97
+ };
98
+ };
99
+ const makePoint = (c) => ({
100
+ latitude: c[1],
101
+ longitude: c[0],
102
+ });
103
+ const makeLine = (l) => l.map(makePoint);
104
+ const makeCoordinatesForAnyPoint = (geometry) => {
105
+ if (geometry.type === 'Point') {
106
+ return [makePoint(geometry.coordinates)];
107
+ }
108
+ return geometry.coordinates.map(makePoint);
109
+ };
110
+ const makeCoordinatesForAnyLine = (geometry) => {
111
+ if (geometry.type === 'LineString') {
112
+ return [makeLine(geometry.coordinates)];
113
+ }
114
+ return geometry.coordinates.map(makeLine);
115
+ };
116
+ const makeCoordinatesForPolygon = (geometry) => {
117
+ return geometry.coordinates.map(makeLine);
118
+ };
119
+ const makeCoordinatesForMultiPolygon = (geometry) => {
120
+ return geometry.coordinates.map(p => p.map(makeLine));
121
+ };
122
+ const getRgbaFromHex = (hex, alpha = 1) => {
123
+ const matchArray = hex.match(/\w\w/g);
124
+ if (!matchArray || matchArray.length < 3) {
125
+ throw new Error('Invalid hex string');
126
+ }
127
+ const [r, g, b] = matchArray.map(x => {
128
+ const subColor = parseInt(x, 16);
129
+ if (Number.isNaN(subColor)) {
130
+ throw new Error('Invalid hex string');
131
+ }
132
+ return subColor;
133
+ });
134
+ return `rgba(${r},${g},${b},${alpha})`;
135
+ };
136
+ const getColor = (prop, overlay, colorType) => {
137
+ if (prop) {
138
+ return prop;
139
+ }
140
+ let color = overlay.feature.properties?.[colorType];
141
+ if (color) {
142
+ const opacityProperty = colorType + '-opacity';
143
+ const alpha = overlay.feature.properties?.[opacityProperty];
144
+ if (alpha && alpha !== '0' && color[0] === '#') {
145
+ color = getRgbaFromHex(color, alpha);
146
+ }
147
+ return color;
148
+ }
149
+ return undefined;
150
+ };
151
+ const getStrokeWidth = (prop, overlay) => {
152
+ if (prop) {
153
+ return prop;
154
+ }
155
+ return overlay.feature.properties?.['stroke-width'];
156
+ };
157
+ // GeoJSON.Feature type-guards
158
+ const isPointFeature = (feature) => feature.geometry.type === 'Point';
159
+ const isMultiPointFeature = (feature) => feature.geometry.type === 'MultiPoint';
160
+ const isAnyPointFeature = (feature) => isPointFeature(feature) || isMultiPointFeature(feature);
161
+ const isLineStringFeature = (feature) => feature.geometry.type === 'LineString';
162
+ const isMultiLineStringFeature = (feature) => feature.geometry.type === 'MultiLineString';
163
+ const isAnyLineStringFeature = (feature) => isLineStringFeature(feature) || isMultiLineStringFeature(feature);
164
+ const isPolygonFeature = (feature) => feature.geometry.type === 'Polygon';
165
+ const isMultiPolygonFeature = (feature) => feature.geometry.type === 'MultiPolygon';
@@ -0,0 +1,40 @@
1
+ import * as React from 'react';
2
+ import { ViewProps } from 'react-native';
3
+ import { MapManagerCommand, NativeComponent, ProviderContext, UIManagerCommand } from './decorateMapComponent';
4
+ import { CalloutPressEvent } from './sharedTypes';
5
+ declare type Props = ViewProps & {
6
+ /**
7
+ * If `true`, clicks on transparent areas in callout will be passed to map.
8
+ *
9
+ * @default false
10
+ * @platform iOS: Supported
11
+ * @platform Android: Not supported
12
+ */
13
+ alphaHitTest?: boolean;
14
+ /**
15
+ * Callback that is called when the user presses on the callout
16
+ *
17
+ * @platform iOS: Apple Maps only
18
+ * @platform Android: Supported
19
+ */
20
+ onPress?: (event: CalloutPressEvent) => void;
21
+ /**
22
+ * If `false`, a default "tooltip" bubble window will be drawn around this callouts children.
23
+ * If `true`, the child views can fully customize their appearance, including any "bubble" like styles.
24
+ *
25
+ * @default false
26
+ * @platform iOS: Supported
27
+ * @platform Android: Supported
28
+ */
29
+ tooltip?: boolean;
30
+ };
31
+ declare type NativeProps = Props;
32
+ export declare class MapCallout extends React.Component<Props> {
33
+ context: React.ContextType<typeof ProviderContext>;
34
+ getNativeComponent: () => NativeComponent<NativeProps>;
35
+ getMapManagerCommand: (name: string) => MapManagerCommand;
36
+ getUIManagerCommand: (name: string) => UIManagerCommand;
37
+ render(): JSX.Element;
38
+ }
39
+ declare const _default: typeof MapCallout;
40
+ export default _default;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.MapCallout = void 0;
27
+ const React = __importStar(require("react"));
28
+ const react_native_1 = require("react-native");
29
+ const decorateMapComponent_1 = __importStar(require("./decorateMapComponent"));
30
+ class MapCallout extends React.Component {
31
+ getNativeComponent;
32
+ getMapManagerCommand;
33
+ getUIManagerCommand;
34
+ render() {
35
+ const { tooltip = false, alphaHitTest = false } = this.props;
36
+ const AIRMapCallout = this.getNativeComponent();
37
+ return (<AIRMapCallout {...this.props} tooltip={tooltip} alphaHitTest={alphaHitTest} style={[styles.callout, this.props.style]}/>);
38
+ }
39
+ }
40
+ exports.MapCallout = MapCallout;
41
+ const styles = react_native_1.StyleSheet.create({
42
+ callout: {
43
+ position: 'absolute',
44
+ },
45
+ });
46
+ exports.default = (0, decorateMapComponent_1.default)(MapCallout, 'Callout', {
47
+ google: {
48
+ ios: decorateMapComponent_1.SUPPORTED,
49
+ android: decorateMapComponent_1.USES_DEFAULT_IMPLEMENTATION,
50
+ },
51
+ });
@@ -0,0 +1,34 @@
1
+ import * as React from 'react';
2
+ import { NativeSyntheticEvent, ViewProps } from 'react-native';
3
+ import { ProviderContext, NativeComponent, MapManagerCommand, UIManagerCommand } from './decorateMapComponent';
4
+ import { Frame, Point } from './sharedTypes';
5
+ declare type Props = ViewProps & {
6
+ /**
7
+ * Callback that is called when the user presses on this subview inside callout
8
+ *
9
+ * @platform iOS: Supported
10
+ * @platform Android: Not supported
11
+ */
12
+ onPress?: (event: CalloutSubviewPressEvent) => void;
13
+ };
14
+ declare type NativeProps = Props;
15
+ export declare class MapCalloutSubview extends React.Component<Props> {
16
+ context: React.ContextType<typeof ProviderContext>;
17
+ getNativeComponent: () => NativeComponent<NativeProps>;
18
+ getMapManagerCommand: (name: string) => MapManagerCommand;
19
+ getUIManagerCommand: (name: string) => UIManagerCommand;
20
+ render(): JSX.Element;
21
+ }
22
+ declare const _default: typeof MapCalloutSubview;
23
+ export default _default;
24
+ declare type CalloutSubviewPressEvent = NativeSyntheticEvent<{
25
+ /**
26
+ * Apple Maps: `callout-inside-press`
27
+ *
28
+ * Google Maps: `marker-inside-overlay-press`
29
+ */
30
+ action: 'callout-inside-press' | 'marker-inside-overlay-press';
31
+ frame: Frame;
32
+ id: string;
33
+ point: Point;
34
+ }>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.MapCalloutSubview = void 0;
27
+ const React = __importStar(require("react"));
28
+ const react_native_1 = require("react-native");
29
+ const decorateMapComponent_1 = __importStar(require("./decorateMapComponent"));
30
+ class MapCalloutSubview extends React.Component {
31
+ getNativeComponent;
32
+ getMapManagerCommand;
33
+ getUIManagerCommand;
34
+ render() {
35
+ const AIRMapCalloutSubview = this.getNativeComponent();
36
+ return (<AIRMapCalloutSubview {...this.props} style={[styles.calloutSubview, this.props.style]}/>);
37
+ }
38
+ }
39
+ exports.MapCalloutSubview = MapCalloutSubview;
40
+ const styles = react_native_1.StyleSheet.create({
41
+ calloutSubview: {},
42
+ });
43
+ exports.default = (0, decorateMapComponent_1.default)(MapCalloutSubview, 'CalloutSubview', {
44
+ google: {
45
+ ios: decorateMapComponent_1.SUPPORTED,
46
+ android: decorateMapComponent_1.NOT_SUPPORTED,
47
+ },
48
+ });