0.1.5 • Published 5 years ago

react-native-mapbox v0.1.5

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

react-native-mapbox

Unofficial MapBox wrapper for React Native around Android and IOS SDKs. There's no official MapBox library. This one covers some basic functionalities like adding markers etc.

Getting started

$ yarn add react-native-mapbox

React Native now automatically links dependencies so you don't need to do anything else other than adding your mapbox key. Grab your key from https://account.mapbox.com/ and follow instrunctions below:

Then in MainApplication.java file need to replace api key with API_KEY below.

import com.mapbox.mapboxsdk.Mapbox;
....

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    Mapbox.getInstance(getApplicationContext(), "YOUR_API_KEY"); // Add this line
  }

Add your API key to MGLMapboxAccessToken in info.plist file.

MGLMapboxAccessToken YOUR_API_KEY

And you're done with installation.

PROPS

Prop NameDescription
cameraCamera Props
optionsOption Props
mapStyleMapStyle Props
markersArray of Marker Props
polylinesArray of Polyline Props
locationPickerBoolean - Whether to show the location picker in the centre of map
onMapReadyCallback when MapBox is ready
onCameraMoveCallback when camera is moving
onCameraMoveEndCallback when camera move action is ended

Camera Props

Prop NameDescription
target{lat, lng} for latitude and longitude
zoomZoom value in numbers
bearingBearing value in numbers
tiltTilt value in numbers

Option Props

Prop NameDescription
showsUserHeadingIndicatorBoolean
showsScaleBoolean
showsHeadingBoolean
showsUserLocationBoolean

MapStyle Props

Prop NameDescription
styleNameString - OOne of "OUTDOORS", "LIGHT", "DARK", "SATELLITE", "SATELLITE_STREETS", "TRAFFIC_DAY"
buildingsBoolean

Marker Props

Prop NameDescription
idString - Identifier for marker. Has to be unique
latNumber - Latitude for marker
lngNumber - Longitude for marker
titleString - Title for marker
SubtitleString - Subtitle for marker
iconObject - Resolved image asset eg. Image.resolveAssetSource(require('img.png'))
pulsatorBoolean or Pulsator Props

Pulsator Props

Prop NameDescription
colorString - hex colour
radiusNumber - radius of pulsator
durationNumber - how many milliseconds the pulsating effect will take

Polyline Props

Prop NameDescription
idString - Identifier for polyline. Has to be unique
coordinatesArray of numbers in Longitude, Latitude format
propertiesObject of Polyline Properties Prop

Polyline Properties Props

Prop NameDescription
nameString - Polyline name
lineWidthNumber
lineColorString - Hex of colour
lineTypeString - dash or don't include for solid

Usage

import {Image,StyleSheet} from 'react-native'
import RNMapBox from 'react-native-mapbox';
import bus from '../images/bus.png'
....

<RNMapBox
  camera={{
    target: {
      lat: -36,
      lng: 174,
    },
    zoom: 6,
  }}
  style={StyleSheet.absoluteFillObject}
  onMapReady={() => console.log('onMapReady callback')}
  markers={[
    {
        id: 'Marker1',
        lat: -36,
        lng: 174,
        title: 'Custom',
        subtitle: 'Sub1',
        icon: Image.resolveAssetSource(bus),
        pulsator: {
          color: '#ff00ff',
          radius: 20,
          duration: 1500
        }
      }
  ]}
/>

Screenshots

OptionsLocationPicker
OptionsLocationPicker
MarkersPolylines
----
MarkersPolylines
0.1.5-alpha-9

5 years ago

0.1.5-alpha-8

5 years ago

0.1.5-alpha-7

5 years ago

0.1.5-alpha-6

5 years ago

0.1.5-alpha-5

5 years ago

0.1.5-alpha-4

5 years ago

0.1.5-alpha-3

5 years ago

0.1.5-alpha-2

5 years ago

0.1.5-alpha-1

5 years ago

0.1.5

5 years ago

0.1.4-alpha-7

5 years ago

0.1.4-alpha-6

5 years ago

0.1.4-alpha-5

5 years ago

0.1.4-alpha-4

5 years ago

0.1.4-alpha-3

5 years ago

0.1.4-alpha-2

5 years ago

0.1.4-alpha-1

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.2

6 years ago

0.0.1

6 years ago