react-native-maps 1.21.0 → 1.22.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.
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/build');
package/package.json CHANGED
@@ -5,13 +5,13 @@
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",
8
+ "version": "1.22.1",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",
12
12
  "tscheck": "tsc --noEmit",
13
13
  "format-check": "prettier --check .",
14
- "build": "tsc --project tsconfig.build.json",
14
+ "build": "tsc --project tsconfig.build.json && tsc --project plugin/tsconfig.json",
15
15
  "test": "jest",
16
16
  "prepare": "husky install",
17
17
  "release": "semantic-release",
@@ -23,6 +23,8 @@
23
23
  "src",
24
24
  "android",
25
25
  "ios",
26
+ "app.plugin.js",
27
+ "plugin/build",
26
28
  "react-native-maps-generated.podspec",
27
29
  "react-native-google-maps.podspec",
28
30
  "react-native-maps.podspec",
@@ -62,6 +64,7 @@
62
64
  "@babel/runtime": "^7.25.0",
63
65
  "@commitlint/cli": "17.6.1",
64
66
  "@commitlint/config-conventional": "17.6.1",
67
+ "@expo/config-plugins": "^9.0.17",
65
68
  "@react-native-community/cli": "15.0.1",
66
69
  "@react-native/babel-preset": "0.76.8",
67
70
  "@react-native/eslint-config": "0.76.8",
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var config_plugins_1 = require("@expo/config-plugins");
40
+ var Manifest_1 = require("@expo/config-plugins/build/android/Manifest");
41
+ var withMapsAndroid = function (config, props) {
42
+ config = (0, config_plugins_1.withAndroidManifest)(config, function (conf) { return __awaiter(void 0, void 0, void 0, function () {
43
+ var manifest, mainApplication;
44
+ return __generator(this, function (_a) {
45
+ manifest = conf.modResults;
46
+ mainApplication = (0, Manifest_1.getMainApplicationOrThrow)(manifest);
47
+ if (props === null || props === void 0 ? void 0 : props.androidGoogleMapsApiKey) {
48
+ (0, Manifest_1.addMetaDataItemToMainApplication)(mainApplication, 'com.google.android.geo.API_KEY', props === null || props === void 0 ? void 0 : props.androidGoogleMapsApiKey);
49
+ }
50
+ else {
51
+ (0, Manifest_1.removeMetaDataItemFromMainApplication)(mainApplication, 'com.google.android.geo.API_KEY');
52
+ }
53
+ return [2 /*return*/, conf];
54
+ });
55
+ }); });
56
+ return config;
57
+ };
58
+ exports.default = withMapsAndroid;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var ios_1 = require("./ios");
4
+ var android_1 = require("./android");
5
+ var withMaps = function (config, props) {
6
+ config = (0, ios_1.withMapsIOS)(config, props);
7
+ config = (0, android_1.default)(config, props);
8
+ return config;
9
+ };
10
+ exports.default = withMaps;
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.addMapsCocoapods = exports.removeGoogleMapsAppDelegateInit = exports.addGoogleMapsAppDelegateInit = exports.removeGoogleMapsAppDelegateImport = exports.addGoogleMapsAppDelegateImport = exports.withMapsIOS = exports.MATCH_INIT = void 0;
40
+ var ios_plugins_1 = require("@expo/config-plugins/build/plugins/ios-plugins");
41
+ var generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
42
+ var debug = require('debug')('expo:config-plugins:ios:maps');
43
+ exports.MATCH_INIT = /\bsuper\.application\(\w+?, didFinishLaunchingWithOptions: \w+?\)/g;
44
+ var withMapsIOS = function (config, props) {
45
+ // Set in Info.plist
46
+ if (props === null || props === void 0 ? void 0 : props.iosGoogleMapsApiKey) {
47
+ config = (0, ios_plugins_1.withInfoPlist)(config, function (conf) { return __awaiter(void 0, void 0, void 0, function () {
48
+ return __generator(this, function (_a) {
49
+ conf.ios.infoPlist.GMSApiKey = props === null || props === void 0 ? void 0 : props.iosGoogleMapsApiKey;
50
+ return [2 /*return*/, conf];
51
+ });
52
+ }); });
53
+ }
54
+ // Technically adds react-native-maps (Apple maps) and google maps.
55
+ debug('Google Maps API Key:', props === null || props === void 0 ? void 0 : props.iosGoogleMapsApiKey);
56
+ config = withMapsCocoaPods(config, {
57
+ useGoogleMaps: !!(props === null || props === void 0 ? void 0 : props.iosGoogleMapsApiKey),
58
+ });
59
+ // Adds/Removes AppDelegate setup for Google Maps API on iOS
60
+ config = withGoogleMapsAppDelegate(config, {
61
+ apiKey: props === null || props === void 0 ? void 0 : props.iosGoogleMapsApiKey,
62
+ });
63
+ return config;
64
+ };
65
+ exports.withMapsIOS = withMapsIOS;
66
+ function addGoogleMapsAppDelegateImport(src) {
67
+ var newSrc = ['#if canImport(GoogleMaps)', 'import GoogleMaps', '#endif'];
68
+ return (0, generateCode_1.mergeContents)({
69
+ tag: 'react-native-maps-import',
70
+ src: src,
71
+ newSrc: newSrc.join('\n'),
72
+ anchor: /@UIApplicationMain/,
73
+ offset: 0,
74
+ comment: '//',
75
+ });
76
+ }
77
+ exports.addGoogleMapsAppDelegateImport = addGoogleMapsAppDelegateImport;
78
+ function removeGoogleMapsAppDelegateImport(src) {
79
+ return (0, generateCode_1.removeContents)({
80
+ tag: 'react-native-maps-import',
81
+ src: src,
82
+ });
83
+ }
84
+ exports.removeGoogleMapsAppDelegateImport = removeGoogleMapsAppDelegateImport;
85
+ function addGoogleMapsAppDelegateInit(src, apiKey) {
86
+ var newSrc = [
87
+ '#if canImport(GoogleMaps)',
88
+ "GMSServices.provideAPIKey(\"".concat(apiKey, "\")"),
89
+ '#endif',
90
+ ];
91
+ return (0, generateCode_1.mergeContents)({
92
+ tag: 'react-native-maps-init',
93
+ src: src,
94
+ newSrc: newSrc.join('\n'),
95
+ anchor: exports.MATCH_INIT,
96
+ offset: 0,
97
+ comment: '//',
98
+ });
99
+ }
100
+ exports.addGoogleMapsAppDelegateInit = addGoogleMapsAppDelegateInit;
101
+ function removeGoogleMapsAppDelegateInit(src) {
102
+ return (0, generateCode_1.removeContents)({
103
+ tag: 'react-native-maps-init',
104
+ src: src,
105
+ });
106
+ }
107
+ exports.removeGoogleMapsAppDelegateInit = removeGoogleMapsAppDelegateInit;
108
+ /**
109
+ * @param src The contents of the Podfile.
110
+ * @returns Podfile with react-native-maps integration configured.
111
+ */
112
+ function addMapsCocoapods(src, useGoogleMaps) {
113
+ var newSrc = ' rn_maps_path = File.dirname(`node --print "require.resolve(\'react-native-maps/package.json\')"`) \n';
114
+ if (useGoogleMaps) {
115
+ newSrc += " pod 'react-native-google-maps', :path => rn_maps_path \n";
116
+ }
117
+ newSrc += " pod 'react-native-maps-generated', :path => rn_maps_path \n";
118
+ return (0, generateCode_1.mergeContents)({
119
+ tag: 'react-native-maps',
120
+ src: src,
121
+ newSrc: newSrc,
122
+ anchor: /use_native_modules/,
123
+ offset: 0,
124
+ comment: '#',
125
+ });
126
+ }
127
+ exports.addMapsCocoapods = addMapsCocoapods;
128
+ var withMapsCocoaPods = function (config, _a) {
129
+ var useGoogleMaps = _a.useGoogleMaps;
130
+ return (0, ios_plugins_1.withPodfile)(config, function (conf) { return __awaiter(void 0, void 0, void 0, function () {
131
+ var results;
132
+ return __generator(this, function (_a) {
133
+ try {
134
+ results = addMapsCocoapods(conf.modResults.contents, useGoogleMaps);
135
+ }
136
+ catch (error) {
137
+ if (error.code === 'ERR_NO_MATCH') {
138
+ throw new Error("Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.");
139
+ }
140
+ throw error;
141
+ }
142
+ if (results.didMerge || results.didClear) {
143
+ conf.modResults.contents = results.contents;
144
+ }
145
+ return [2 /*return*/, conf];
146
+ });
147
+ }); });
148
+ };
149
+ var withGoogleMapsAppDelegate = function (config, _a) {
150
+ var apiKey = _a.apiKey;
151
+ return (0, ios_plugins_1.withAppDelegate)(config, function (conf) {
152
+ if (!apiKey) {
153
+ conf.modResults.contents = removeGoogleMapsAppDelegateImport(conf.modResults.contents).contents;
154
+ conf.modResults.contents = removeGoogleMapsAppDelegateInit(conf.modResults.contents).contents;
155
+ return conf;
156
+ }
157
+ if (conf.modResults.language !== 'swift') {
158
+ throw new Error("Cannot setup Google Maps because the project AppDelegate is not a supported language: ".concat(conf.modResults.language));
159
+ }
160
+ try {
161
+ conf.modResults.contents = addGoogleMapsAppDelegateImport(conf.modResults.contents).contents;
162
+ conf.modResults.contents = addGoogleMapsAppDelegateInit(conf.modResults.contents, apiKey).contents;
163
+ }
164
+ catch (error) {
165
+ if (error.code === 'ERR_NO_MATCH') {
166
+ throw new Error("Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.");
167
+ }
168
+ throw error;
169
+ }
170
+ return conf;
171
+ });
172
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/src/MapView.tsx CHANGED
@@ -752,13 +752,13 @@ class MapView extends React.Component<MapViewProps, State> {
752
752
  private map: NativeProps['ref'];
753
753
 
754
754
  private fabricMap =
755
- React.createRef<FabricMapHandle | null>() as React.RefObject<FabricMapHandle>;
755
+ React.createRef<FabricMapHandle | null>() as React.RefObject<FabricMapHandle | null>;
756
756
 
757
757
  constructor(props: MapViewProps) {
758
758
  super(props);
759
759
 
760
760
  this.map = React.createRef<MapViewNativeComponentType>();
761
- this.fabricMap = React.createRef<FabricMapHandle>();
761
+ this.fabricMap = React.createRef<FabricMapHandle | null>();
762
762
  this.state = {
763
763
  isReady: false,
764
764
  };
@@ -1113,6 +1113,12 @@ class MapView extends React.Component<MapViewProps, State> {
1113
1113
  }
1114
1114
  };
1115
1115
 
1116
+ private handleLongPress = (event: NativeSyntheticEvent<any>) => {
1117
+ if (this.props.onLongPress) {
1118
+ this.props.onLongPress(event);
1119
+ }
1120
+ };
1121
+
1116
1122
  render() {
1117
1123
  // Define props specifically for MapFabricNativeProps
1118
1124
  /* eslint-disable @typescript-eslint/no-unused-vars */
@@ -1164,6 +1170,7 @@ class MapView extends React.Component<MapViewProps, State> {
1164
1170
  onIndoorBuildingFocused: this.handleIndoorBuildingFocused,
1165
1171
  // @ts-ignore
1166
1172
  onIndoorLevelActivated: this.handleIndoorLevelActivated,
1173
+ onLongPress: this.handleLongPress,
1167
1174
  ...restProps,
1168
1175
  };
1169
1176
  if (this.props.region) {
@@ -1,2 +1,2 @@
1
- export const PROVIDER_DEFAULT = undefined;
1
+ export const PROVIDER_DEFAULT: any = undefined;
2
2
  export const PROVIDER_GOOGLE = 'google';
@@ -50,9 +50,11 @@ function getNativeComponentName(provider: Provider, component: ComponentName) {
50
50
  return `${getNativeMapName(provider)}${component}`;
51
51
  }
52
52
 
53
- export const createNotSupportedComponent = (message: string) => () => {
54
- console.error(message);
55
- return null;
53
+ export const createNotSupportedComponent = (message: string): (() => null) => {
54
+ return () => {
55
+ console.error(message);
56
+ return null;
57
+ };
56
58
  };
57
59
 
58
60
  export const googleMapIsInstalled = !!UIManager.hasViewManagerConfig(