user2438904
user2438904

Reputation: 1

I am trying to run MapLibreGL in React Native but get an error "Cannot read property 'StyleURL' of null"

I created a React Native project with Expo. I have imported the library @malibre/malibre-react-native and added this code in my component:

    <View style={styles.page}>
      <MapLibreGL.MapView
        ref={mapviewRef}
        style={styles.map}
        logoEnabled={false}
        styleURL="https://map.ir/vector/styles/main/mapir-Dove-style.json"
        attributionControl={false} // Remove attribution for cleaner UI
      />
    </View>

enter image description here

But every time I run it, I get:

R Native part of Mapbox React Native libraries were not registered properly, double check our native installation guides.

ERROR TypeError: Cannot read property 'StyleURL' of null, js engine: hermes

Upvotes: 0

Views: 223

Answers (2)

Ryuji Damna
Ryuji Damna

Reputation: 1

Same issue, you can still use the main lib mapLibre to create a webview with the "use dom" directive. it the same process and after for production replace with the react-native-maplibre lib

Upvotes: 0

Sherif
Sherif

Reputation: 11

Are you trying to run the code in Expo Go? This will not work. You will need to "eject" your code into a bare react native flow. To do this, follow the steps to create a development build on Expo. If you had done this already, you will need to rebuild your code after you install the maplibre library.

Upvotes: 1

Related Questions