Skip to content

Instantly share code, notes, and snippets.

@kevinchisholm
Last active December 24, 2017 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinchisholm/3dec61ce84baf01c5b036166bb7ed908 to your computer and use it in GitHub Desktop.
Save kevinchisholm/3dec61ce84baf01c5b036166bb7ed908 to your computer and use it in GitHub Desktop.
Getting Started with the Mapbox Maps SDK for React Native
import React, {Component} from 'react';
import {View} from 'react-native';
import MapboxGL from '@mapbox/react-native-mapbox-gl';
MapboxGL.setAccessToken(YOUR_ACCES_TOKEN);
export default class App extends Component<{}> {
render () {
return (
<View style={{flex: 1}}>
<MapboxGL.MapView
ref={(c) => this._map = c}
style={{flex: 1}}>
</MapboxGL.MapView>
</View>
);
}
}
import React, {Component} from 'react';
import {View} from 'react-native';
import MapboxGL from '@mapbox/react-native-mapbox-gl';
MapboxGL.setAccessToken(YOUR_ACCES_TOKEN);
export default class App extends Component<{}> {
render () {
return (
<View style={{flex: 1}}>
<MapboxGL.MapView
ref={(c) => this._map = c}
style={{flex: 1}}
zoomLevel={1}>
</MapboxGL.MapView>
</View>
);
}
}
import React, {Component} from 'react';
import {View} from 'react-native';
import MapboxGL from '@mapbox/react-native-mapbox-gl';
MapboxGL.setAccessToken(YOUR_ACCES_TOKEN);
const columbusCircleCoordinates = [
-73.98197650909422, 40.768793007758816
];
export default class App extends Component<{}> {
render () {
return (
<View style={{flex: 1}}>
<MapboxGL.MapView
ref={(c) => this._map = c}
style={{flex: 1}}
zoomLevel={15}
centerCoordinate={columbusCircleCoordinates}>
</MapboxGL.MapView>
</View>
);
}
}
{
"name": "mapboxSdkExample",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"@mapbox/react-native-mapbox-gl": "^6.0.2",
"react": "16.0.0",
"react-native": "0.51.0"
},
"devDependencies": {
"babel-jest": "22.0.4",
"babel-preset-react-native": "4.0.0",
"jest": "22.0.4",
"react-test-renderer": "16.0.0"
},
"jest": {
"preset": "react-native"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment