nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 699 forks source link

[Android] Http code 401, loading style failed #1685

Open jawwad22 opened 4 years ago

jawwad22 commented 4 years ago

Hi, Done everything according to this https://github.com/react-native-mapbox-gl/maps/blob/master/docs/GettingStarted.md

simply trying to run a but getting this error

my code import React, { Component } from "react"; import { StyleSheet, View } from "react-native"; import MapboxGL from "@react-native-mapbox-gl/maps";

MapboxGL.setAccessToken(sk.eyJ1IjoidGVzdG1hcGJveDIyIiwiYSI6ImNrYmtjaXY5MTB4aW4ycmxzZWp2cG0wa2YifQ.vZizWDkI67FBUFQSHCinmA );

const styles = StyleSheet.create({ page: { flex: 1, justifyContent: "center", alignItems: "center", backgroundColor: "#F5FCFF" }, container: { height: 300, width: 300, backgroundColor: "tomato" }, map: { flex: 1 } });

export default class App extends Component { componentDidMount() { MapboxGL.setTelemetryEnabled(false); }

render() { return (

);

} }

thangpham7793 commented 2 years ago

Hey I think you need a public access token, starts with pk to use with setAccessToken.

What you had there seems to be a secret token, sk.... That's probably needs to go to your gradle.properties file in inside android folder so that the android side can download maps.

When I set it up I needed to go through the steps for android here. https://github.com/react-native-mapbox-gl/maps/blob/master/android/install.md