All Projects β†’ amaurym β†’ React Mapbox Gl Draw

amaurym / React Mapbox Gl Draw

Licence: mit
Draw tools for Mapbox with React: πŸ—ΊοΈ react-mapbox-gl + πŸ–ŒοΈ mapbox-gl-draw

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React Mapbox Gl Draw

angular-mapboxgl-directive
AngularJS directive for Mapbox GL
Stars: ✭ 43 (-68.38%)
Mutual labels:  mapbox-gl
React Map Gl
React friendly API wrapper around MapboxGL JS
Stars: ✭ 6,244 (+4491.18%)
Mutual labels:  mapbox-gl
Maplibre Gl Native
An open-source fork of Mapbox GL SDK for iOS and Android and other platforms
Stars: ✭ 65 (-52.21%)
Mutual labels:  mapbox-gl
Mapdeck
R interface to Deck.gl and Mapbox
Stars: ✭ 296 (+117.65%)
Mutual labels:  mapbox-gl
Martin
Blazing fast and lightweight PostGIS vector tiles server
Stars: ✭ 540 (+297.06%)
Mutual labels:  mapbox-gl
Openstreetmap Cartographic
A port of OpenStreetMap Carto to Mapbox GL for client-side rendering
Stars: ✭ 50 (-63.24%)
Mutual labels:  mapbox-gl
airbnb-ish
Airbnb UI clone using Next.js + styled-components.
Stars: ✭ 122 (-10.29%)
Mutual labels:  mapbox-gl
Mapbox Gl Native Android
Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL
Stars: ✭ 135 (-0.74%)
Mutual labels:  mapbox-gl
Mapbox Gl Draw
Draw tools for mapbox-gl-js
Stars: ✭ 569 (+318.38%)
Mutual labels:  mapbox-gl
Editor
An open source visual editor for the 'Mapbox Style Specification'
Stars: ✭ 1,167 (+758.09%)
Mutual labels:  mapbox-gl
React Map Gl
React Component Library for Mapbox GL JS
Stars: ✭ 298 (+119.12%)
Mutual labels:  mapbox-gl
Mapbox Gl Native
Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
Stars: ✭ 4,091 (+2908.09%)
Mutual labels:  mapbox-gl
Harmoware Vis
Spatial-Temporal Visualization Library using Deck.GL
Stars: ✭ 51 (-62.5%)
Mutual labels:  mapbox-gl
Mappa
A canvas wrapper for Maps πŸ—Ί 🌍
Stars: ✭ 290 (+113.24%)
Mutual labels:  mapbox-gl
Osmscout Server
Maps server providing tiles, geocoder, and router
Stars: ✭ 105 (-22.79%)
Mutual labels:  mapbox-gl
mapbox-filter
Utilities for filtering vector mbitles files according to Mapbox GL styles
Stars: ✭ 24 (-82.35%)
Mutual labels:  mapbox-gl
Mapbox Gl Js
Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
Stars: ✭ 8,017 (+5794.85%)
Mutual labels:  mapbox-gl
Pure Maps
Maps and navigation
Stars: ✭ 136 (+0%)
Mutual labels:  mapbox-gl
React Mapbox Gl
A React binding of mapbox-gl-js
Stars: ✭ 1,683 (+1137.5%)
Mutual labels:  mapbox-gl
Makina Maps
Full Stack to Build, Serve and Update your own Vector and Raster Tiles from OpenStreetMap Data.
Stars: ✭ 52 (-61.76%)
Mutual labels:  mapbox-gl

react-mapbox-gl-draw

Actions Status npm npm dependencies Status

Draw tools for Mapbox with React: πŸ—ΊοΈ react-mapbox-gl + πŸ–ŒοΈ mapbox-gl-draw

This package is basically creating React bindings for mapbox-gl-draw so that it can be used with react-mapbox-gl.

❗ Important: This package does not work with Uber's react-map-gl. See this issue for more info.

Demo

See https://codesandbox.io/s/xenodochial-tu-pwly8.

Getting Started

yarn add react-mapbox-gl mapbox-gl @mapbox/mapbox-gl-draw # required peer dependencies
yarn add react-mapbox-gl-draw

Note: this version of react-mapbox-gl-draw will only work with the latest [email protected]^4.4.0. If you wish to use Draw tools with [email protected] or [email protected], please use [email protected].

import ReactMapboxGl from 'react-mapbox-gl';
import DrawControl from 'react-mapbox-gl-draw';

// Don't forget to import the CSS
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';

const Map = ReactMapboxGl({
  accessToken:
    'pk.eyJ1IjoiZmFrZXVzZXJnaXRodWIiLCJhIjoiY2pwOGlneGI4MDNnaDN1c2J0eW5zb2ZiNyJ9.mALv0tCpbYUPtzT7YysA2g'
});

<Map
  style="mapbox://styles/mapbox/streets-v9"
  containerStyle={{
    height: '100vh',
    width: '100vw'
  }}
>
  <DrawControl />
</Map>;

API

Here are the props you can pass to <DrawControl />:

  • keybindings, boolean (default true): Whether or not to enable keyboard interactions for drawing.
  • touchEnabled, boolean (default true): Whether or not to enable touch interactions for drawing.
  • boxSelect, boolean (default true): Whether or not to enable box selection of features with shift+click+drag. If false, shift+click+drag zooms into an area.
  • clickBuffer, number (default: 2): Number of pixels around any feature or vertex (in every direction) that will respond to a click.
  • touchBuffer, number (default: 25): Number of pixels around any feature of vertex (in every direction) that will respond to a touch.
  • controls, Object: Hide or show individual controls. Each property's name is a control, and value is a boolean indicating whether the control is on or off. Available control names are point, line_string, polygon, trash, combine_features and uncombine_features. By default, all controls are on. To change that default, use displayControlsDefault.
  • displayControlsDefault, boolean (default: true): The default value for controls. For example, if you would like all controls to be off by default, and specify a whitelist with controls, use displayControlsDefault: false.
  • styles, Array<Object>: An array of map style objects. By default, Draw provides a map style for you. To learn about overriding styles, see the Styling Draw section below.
  • modes, Object: over ride the default modes with your own. MapboxDraw.modes can be used to see the default values. More information on custom modes can be found here.
  • defaultMode, String (default: 'simple_select'): the mode (from modes) that user will first land in.
  • userProperties, boolean (default: false): properties of a feature will also be available for styling and prefixed with user_, e.g., ['==', 'user_custom_label', 'Example']

Also see the API reference for mapbox-gl-draw.

Draw Events passed as props

These additional props are functions that receive the event data, see mapbox-gl-draw documentantion.

  • onDrawCreate
  • onDrawDelete
  • onDrawUpdate
  • onDrawCombine
  • onDrawUncombine
  • onDrawSelectionChange
  • onDrawModeChange
  • onDrawRender
  • onDrawActionable

To learn more about mapbox-gl-draw: https://github.com/mapbox/mapbox-gl-draw/blob/master/docs/API.md

To access the Draw object with all the API methods, you need to define a ref on the <DrawControl> component, and the Draw object will be in the draw field of this ref:

<Map
  style="mapbox://styles/mapbox/streets-v9"
  containerStyle={{
    height: '100vh',
    width: '100vw'
  }}>
    <DrawControl
      ref={(drawControl) => { this.drawControl = drawControl; }}
    />
</Map>

//...
handleButtonClick() {
  this.drawControl.draw.getAll(); // Or any other API method
}

Example

An example application of how to use react-mapbox-gl-draw can be found in the example/ folder. To run it, run:

yarn example

The example app should run on localhost:8080. An online demo is also hosted on CodeSandbox: https://codesandbox.io/s/xenodochial-tu-pwly8.

Testing

Only eslint is run for linting. Proper testing needs to be added, see #19 if you would like to help.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].