Error: Tried to register two views with the same name AIRMap... while implementing react-native-maps

Viewed 3750

I use react-native-maps, here's my code:

import { Marker} from 'react-native-maps';
import { MapView} from 'expo';
          <MapView
                style={{ flex: 1, height: 300 }}
                initialRegion={{
                  latitude: 37.78825,
                  longitude: -122.4324,
                  latitudeDelta: 0.0922,
                  longitudeDelta: 0.0421,
                }}>
                <Marker
                  coordinate={{
                    latitude: 39.78825,
                    latitude: 39.78825,
                  }}
                  title="Title"
                  description={"Desc"}
                />
           </MapView>

It returns error: "Tried to register two views with the same name AIRMap" Please help. Thanks.

4 Answers

Could you provide the dependencies list, Accessing Expo.MapView just requires react-native-maps. Could you perhaps have two copies of react-native-maps installed?

This may happen when dependencies are corrupt for some reason. Try deleting your package-lock.json (or yarn.lock) and node_modules folder, then run npm install (or yarn) again.

Use:

import MapView from 'react-native-maps';

Make sure you add this code to your android/app/src/main/AndroidManifest.xml

<application>
   <!-- You will only need to add this meta-data tag, but make sure it's a child of application -->
   <meta-data
     android:name="com.google.android.geo.API_KEY"
     android:value="Your Google maps API Key Here"/>
</application>
Related