question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[iOS] Cannot create property 'create' of undefined (MapboxGL.StyleSheet.create)

See original GitHub issue

Describe the bug I am trying to create a simple map with custom styling on FillLayer, however I am unable to declare styling. Trying MapboxGL.StyleSheet.create results in Cannot create property 'create' of undefined. Only tested on iOS so far. On actual device the error is undefined is not an object (evaluating _maps.default.StyleSheet.create).

To Reproduce

  1. Create a new react native app
  2. Install @react-native-mapbox/maps
  3. Replace App.js into the following code
import React, { Component } from "react";
import { StyleSheet, View, Dimensions } from "react-native";
import MapboxGL from "@react-native-mapbox/maps";

const { height: screenHeight, width: screenWidth } = Dimensions.get("window");

MapboxGL.setAccessToken("<your token>");

const mapStyle = MapboxGL.StyleSheet.create({
  buildings: {
    fillColor: "blue"
  },
  street: {
    lineColor: "green"
  }
});

export default class App extends Component {
  render() {
    const height = screenHeight;
    const width = screenWidth;

    return (
      <View style={styles.container}>
        <MapboxGL.MapView
          style={{ height, width }}
          onDidFailLoadingMap={error => {
            console.log(error);
          }}
          zoomLevel={17}
          zoomEnabled
        >
          <MapboxGL.Camera followZoomLevel={12} />
          <MapboxGL.FillLayer style={mapStyle.buildings} />
        </MapboxGL.MapView>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#F5FCFF"
  }
});

Expected behavior A map is rendered with the styles applied to the fill layer.

Screenshots If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • Platfrom: iOS
  • Device: Simulator
  • OS: iOS 12.2
  • SDK Version: Latest
  • React Native Version: 0.59.8

Additional context Without MapboxGL.StyleSheet.create the example above works.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
mfazekascommented, May 27, 2019

@HPieters yes thanks for the issue i hope i’ve clarified it in migrations notes in changelog

0reactions
HPieterscommented, May 27, 2019

Seems to work great, thanks once again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[iOS] Cannot create property 'create' of undefined (MapboxGL ...
I am trying to create a simple map with custom styling on FillLayer, however I am unable to declare styling. Trying MapboxGL.StyleSheet.create ......
Read more >
rnmapbox/Lobby - Gitter
Hey,. is it possible to use an uri as source for the iconImage in a MapboxGl.SymbolLayer? I tried two things: First: const styles...
Read more >
Cannot display MAP from react-map-gl and Mapbox
1 Answer 1 · Make sure the mapStyle from Studio mapbox and mapboxApiAccessToken are correctly paired. · The width and height in viewport...
Read more >
mapbox-gl | Yarn - Package Manager
Mapbox GL JS is a JavaScript library for interactive, customizable vector maps on the web ... Add support for cameraForBounds with globe projection...
Read more >
Styles | Mapbox Studio manual
Without layers, you cannot see your data. You can create multiple layers from the same data and you can filter data by attributes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found