New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-mapbox-gl

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps

  • 0.0.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
56
decreased by-25.33%
Maintainers
1
Weekly downloads
 
Created
Source

React Native Mapbox GL

A react native component for accessing Mapbox GL

Installation Process

  1. npm install react-native-mapbox-gl --save
  2. In the XCode's Project navigator, right click on project's name ➜ Add Files to <...>
  3. Add node_modules/react-native-mapbox-gl/RCTMapboxGL.xcodeproj
  4. Select your project in the Project navigator. Click Build Phases then Link Binary With Libraries. Add node_modules/react-native-mapbox-gl/RCTMapboxGL/libRCTMapboxGL.a
  5. Select your project in the Project navigator. Click Build Phases then Copy Bundle Resources. Click the + button. When the modal appears, click Add other. Add node_modules/react-native-mapbox-gl/RCTMapboxGL/MapboxGL.bundle.
  6. Add the following Cocoa framework dependencies to your target's Link Binary With Libraries build phase:
  • CoreTelephony.framework
  • GLKit.framework
  • ImageIO.framework
  • MobileCoreServices.framework
  • QuartzCore.framework
  • SystemConfiguration.framework
  • libc++.dylib
  • libsqlite3.dylib
  • libz.dylib
  1. Click on the RCTMapboxGL project. Under the Build Settings tab, search for header_search_path. Make sure $(SRCROOT)/../../React and $(SRCROOT)/../react-native/React are added and set to recursive.
  2. You can now require(react-native-mapbox-gl) and build.

Information on installing Mapbox GL for iOS normally

Options

OptionTypeOpt/RequiredDefaultNote
accessTokenstringRequiredNAMapbox access token. Sign up for a Mapbox account here.
centerCoordinateobjectOptional0,0Initial latitude/longitude the map will load at, defaults to 0,0.
zoomLeveldoubleOptional0Initial zoom level the map will load at. 0 is the entire world, 18 is rooftop level. Defaults to 0.
rotateEnabledboolOptionaltrueWhether the map can rotate
showsUserLocationboolOptionalfalseWhether the users location is shown on the map. Note - the map will
styleURLstringOptionalMapbox StreetsA Mapbox GL style sheet. Defaults to mapbox-streets. More styles can be viewed here.
annotationsarrayOptionalNAAn array of annotation objects. latitude/longitude are required, both title and subtitle are optional.
directiondoubleOptional0Heading of the map in degrees where 0 is north and 180 is south
debugActiveboolOptionalfalseTurns on debug mode.
styleflexbox viewOptionalNAStyles the actual map view container

GL Styles

You can change the styleURL to any valid GL stylesheet, here are a few:

  • asset://styles/basic-v7.json
  • asset://styles/bright-v7.json
  • asset://styles/dark-v7.json
  • asset://styles/emerald-v7.json
  • asset://styles/light-v7.json
  • asset://styles/mapbox-streets-v7.json
  • asset://styles/outdoors-v7.json
  • asset://styles/satellite-v7.json

Events

Event NameReturnsNotes
onRegionChange{latitude: 0, longitude: 0, zoom: 0}Triggered by panning or zooming the map.

Example MapboxGLMap:

'use strict';

var React = require('react-native');
var MapboxGLMap = require('react-native-mapbox-gl');

var {
  AppRegistry,
  StyleSheet,
  View,
  Text
} = React;

var map = React.createClass({
  getInitialState: function() {
    return {
      regionLocation: {
        latitude: 0,
        longitude: 0
      },
      zoom: 12,
      direction: 0
    }
  },
  onChange: function(e) {
    this.setState({ regionLocation: e });
  },
  render: function() {
    var center = {
      latitude: 40.72345355209305,
      longitude: -73.99343490600586
    };
    var annotations = [{
      latitude: 40.72052634,
      longitude:  -73.97686958312988,
      title: 'This is marker 1',
      subtitle: 'Hi mom!'
    },{
      latitude: 40.714541341726175,
      longitude:  -74.00579452514648,
      title: 'This is marker 2',
      subtitle: 'Neat, this is a subtitle'
    }];
    return (
      <View style={styles.container}>
        <MapboxGLMap
          style={styles.map}
          rotateEnabled={true}
          showsUserLocation={true}
          accessToken={'your-mapbox.com-access-token'}
          styleURL={'asset://styles/mapbox-streets-v7.json'}
          centerCoordinate={center}
          zoomLevel={this.state.zoom}
          onResetNorth={this.onResetNorth}
          debugActive={false}
          direction={this.state.direction}
          annotations={annotations}
          onRegionChange={this.onChange}/>
        <View style={styles.text}>
          <Text>Latitude: {this.state.regionLocation.latitude}</Text>
          <Text>Longitude: {this.state.regionLocation.longitude}</Text>
          <Text>zoom level: {this.state.regionLocation.zoom}</Text>
        </View>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flexDirection: 'column',
    flex: 1
  },
  map: {
    flex:5,
  },
  text: {
    padding: 20
  }
});

AppRegistry.registerComponent('yourProjectName', () => map);

Keywords

FAQs

Package last updated on 10 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc