简体   繁体   中英

Native component for "AIRMap" does not exist

react-native: 0.53.3
react-native-maps@0.20.1

I'm trying to use react-native-maps and I keep getting this error. This is in a fresh project:

react-native init maps
cd maps/
npm install --save react-native-maps
react-native run-ios

And in App.js I've added this:

...
import MapView from 'react-native-maps';

export default class App extends Component<Props> {
  render() {
    return (
      <View>
      <MapView
      initialRegion={{
        latitude: 37.78825,
        longitude: -122.4324,
        latitudeDelta: 0.0922,
        longitudeDelta: 0.0421,
      }}
    />
    </View>
    );
  }
}

This seems to be the bare minimum to get this running, but my iOS simulator is complaining about "AIRMap".

在此处输入图片说明

In my case I had the same result after following the instructions and the solution at the end was really simple.

I went to Xcode -> Clean -> Build.

There I saw that I had 2 errors in my code:

  1. Expected ';' after module name (@import GoogleMaps)

  2. Use of undeclared identifier ([GMSPlacesClient provideAPIKey:@"MY_KEY"];)

So, I added ';' and deleted the line GMSPlacesClient provideAPIKey:@"MY_KEY"];

After that I executed again 'npm run ios' and all worked like a charm!

There are other solutions here:

  1. https://github.com/react-community/react-native-maps/issues/1798

  2. https://github.com/react-community/react-native-maps/issues/2064

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM