Skip to content

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

@HPieters

Description

@HPieters

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions