Commit 960a8cb8 authored by Cedar Studios's avatar Cedar Studios

Add README.md

parents
# Mapbox Maps SDK for React Native (CedarMaps Variant)
_An unofficial React Native component for building maps with the [Mapbox Maps SDK for iOS](https://www.mapbox.com/ios-sdk/) and [Mapbox Maps SDK for Android](https://www.mapbox.com/android-sdk/)_
## Installation
**Dependencies**
* [node](https://nodejs.org)
* [npm](https://www.npmjs.com/)
* [React Native](https://facebook.github.io/react-native/) recommended version 0.50 or greater
**Git**
```
git clone git@github.com:mapbox/react-native-mapbox-gl.git
cd react-native-mapbox-gl
```
**Yarn**
```
yarn add @mapbox/react-native-mapbox-gl
```
**Npm**
```
npm install @mapbox/react-native-mapbox-gl --save
```
## Installation Guides
* [Android](https://github.com/mapbox/react-native-mapbox-gl/blob/master/android/install.md)
* [iOS](https://github.com/mapbox/react-native-mapbox-gl/blob/master/ios/install.md)
* [Mapbox Example](https://github.com/mapbox/react-native-mapbox-gl/blob/master/example) (Not using CedarMaps; for demonstration purposes)
## Initializing a Map
Once you’ve set up your development environment, created a new React Native project, and installed the Mapbox Maps SDK for React Native, you’re ready to initialize a map in your App.js file.
First, you’ll import the components that you will need. This includes components from React, React Native, and Mapbox. To display a map you’ll need a CedarMaps access token. CedarMaps uses access tokens to associate requests to API resources with your account. As soon as you have imported Mapbox, you should set your CedarMaps access token using Mapbox.setAccessToken().
Then, use the Mapbox.MapView component to initialize your map. The MapView component will add a map to the view, and you can add props to specify some parameters for the map including the map style, zoom level, and center of the map.
Here’s the complete code to display a map:
```js
import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import Mapbox from '@mapbox/react-native-mapbox-gl';
const cedarAccessToken = "YOUR_CEDARMAPS_ACCESS_TOKEN";
Mapbox.setAccessToken('pk.' + cedarAccessToken); //This line is mandatory. Notice you have to add 'pk.' to CedarMaps access token and pass it to Mapbox
export default class App extends Component<{}> {
render() {
return (
<View style={styles.container}>
<Mapbox.MapView
styleURL={"https://api.cedarmaps.com/v1/styles/cedarmaps.light.json" + "?access_token=" + cedarAccessToken}
zoomLevel={15}
centerCoordinate={[51.4093, 35.7546]}
logoEnabled={false}
attributionEnabled={false}
style={styles.container}>
</Mapbox.MapView>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
}
});
```
Other possible values for ```styleURL``` are:
* ```{https://api.cedarmaps.com/v1/styles/cedarmaps.dark.json" + "?access_token=" + cedarAccessToken}```
* ```{"https://api.cedarmaps.com/v1/styles/cedarmaps.light.json" + "?access_token=" + cedarAccessToken}```
* ```{"https://api.cedarmaps.com/v1/tiles/light.json"} + "?access_token=" + cedarAccessToken}```
## Documentation
### Components
* [MapView](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/MapView.md)
* [Light](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/Light.md)
* [StyleSheet](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/StyleSheet.md)
* [PointAnnotation](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/PointAnnotation.md)
* [Callout](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/Callout.md)
### Sources
* [VectorSource](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/VectorSource.md)
* [ShapeSource](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/ShapeSource.md)
* [RasterSource](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/RasterSource.md)
### Layers
* [BackgroundLayer](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/BackgroundLayer.md)
* [CircleLayer](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/CircleLayer.md)
* [FillExtrusionLayer](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/FillExtrusionLayer.md)
* [FillLayer](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/FillLayer.md)
* [LineLayer](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/LineLayer.md)
* [RasterLayer](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/RasterLayer.md)
* [SymbolLayer](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/SymbolLayer.md)
### Offline
* [OfflineManager](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/OfflineManager.md)
* [SnapshotManager](https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/snapshotManager.md)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment