All Projects → TerraEclipse → react-mapboxgl

TerraEclipse / react-mapboxgl

Licence: other
Declarative React components for mapbox-gl-js.

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to react-mapboxgl

Martin
Blazing fast and lightweight PostGIS vector tiles server
Stars: ✭ 540 (+3500%)
Mutual labels:  mapbox-gl, mapbox-gl-js, mapbox
angular-mapboxgl-directive
AngularJS directive for Mapbox GL
Stars: ✭ 43 (+186.67%)
Mutual labels:  mapbox-gl, mapbox-gl-js, mapbox
deck.gl-time-series-widget
A React Time Slider implementation for DECK.GL - (non)temporal data - by CPU filtering ⌛
Stars: ✭ 19 (+26.67%)
Mutual labels:  mapbox-gl, mapbox-gl-js, mapbox
Mapdeck
R interface to Deck.gl and Mapbox
Stars: ✭ 296 (+1873.33%)
Mutual labels:  mapbox-gl, mapbox-gl-js, mapbox
Mapbox Gl Js
Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
Stars: ✭ 8,017 (+53346.67%)
Mutual labels:  mapbox-gl, mapbox-gl-js, mapbox
maptalks.mapboxgl
MapboxglLayer for maptalks.js
Stars: ✭ 51 (+240%)
Mutual labels:  mapbox-gl, mapbox-gl-js, mapbox
Mapbox Gl Draw
Draw tools for mapbox-gl-js
Stars: ✭ 569 (+3693.33%)
Mutual labels:  mapbox-gl, mapbox-gl-js
React Map Gl
React friendly API wrapper around MapboxGL JS
Stars: ✭ 6,244 (+41526.67%)
Mutual labels:  mapbox-gl, mapbox-gl-js
Editor
An open source visual editor for the 'Mapbox Style Specification'
Stars: ✭ 1,167 (+7680%)
Mutual labels:  mapbox-gl, mapbox-gl-js
Mapbox Gl Native Android
Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL
Stars: ✭ 135 (+800%)
Mutual labels:  mapbox-gl, mapbox
React Map Gl
React Component Library for Mapbox GL JS
Stars: ✭ 298 (+1886.67%)
Mutual labels:  mapbox-gl, mapbox-gl-js
Maplibre Gl Native
An open-source fork of Mapbox GL SDK for iOS and Android and other platforms
Stars: ✭ 65 (+333.33%)
Mutual labels:  mapbox-gl, mapbox
react-map-gl-cluster
Urbica React Cluster Component for Mapbox GL JS
Stars: ✭ 27 (+80%)
Mutual labels:  mapbox-gl, mapbox-gl-js
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 (+27173.33%)
Mutual labels:  mapbox-gl, mapbox
Vue Mapbox
Vuejs 2 components for interacting with mapbox-gl-js
Stars: ✭ 359 (+2293.33%)
Mutual labels:  mapbox-gl, mapbox
React Mapbox Gl
A React binding of mapbox-gl-js
Stars: ✭ 1,683 (+11120%)
Mutual labels:  mapbox-gl, mapbox-gl-js
Osm Liberty
A free Mapbox GL basemap style for everyone
Stars: ✭ 231 (+1440%)
Mutual labels:  mapbox-gl, mapbox-gl-js
react-map-gl-draw
React Component for Mapbox GL Draw
Stars: ✭ 50 (+233.33%)
Mutual labels:  mapbox-gl, mapbox-gl-js
Mappa
A canvas wrapper for Maps 🗺 🌍
Stars: ✭ 290 (+1833.33%)
Mutual labels:  mapbox-gl, mapbox
Terramach
Terra Mach is a mapping frontend system to build graphical interfaces for devices.
Stars: ✭ 142 (+846.67%)
Mutual labels:  mapbox-gl, mapbox

@react-mapboxgl

About

This aims to be as close of a 1-to-1 mapping of the mapbox-gl-js API to react as possible. It takes the largely imperative mapbox-gl-js codebase and wraps it in declarative react components. A few goals:

  • Declarative way to create mapbox-gl maps.
  • Support as close to 100% of the mapbox-gl-js API as makes sense.
  • Leverage the mapbox-gl-js way of doing things wherever possible.
  • "Everything is a component"
    • You should be able to do thinks like render layers, bind click handlers, respond to hovering over layers, ect. by merely rendering components.
    • Many maps will only need a render method, no state to juggle.
    • The core attempts to split things out to composable components wherever possible.

Inspired and bootstrapped from react-mapbox-gl.

Installation

Currently, this module needs to be bundled by your app. If you are already using something like webpack or rollup, you should be good to go. It requires installing some peer dependencies. I chose this to avoid increasing the bundle size if you're already using some of these libraries.

$ npm install --save @react-mapboxgl/core mapbox-gl lodash react prop-types

Documentation

Documentation and examples can be found in the storybook.

Sandbox

You can easily play around with maps on codesandbox.io:

Edit @react-mapboxgl Playground

Quick Example

This renders a map, adds a source and layer to the map, and changes the fill of polygon features when they are hovered. See it in action in the storybook.

Hover map example

import React from 'react'
import {MapboxProvider, MapGL, Source, Layer} from '@react-mapboxgl/core'
import Hover from '@react-mapboxgl/hover'

const mapOptions = {
  style: 'mapbox://styles/mapbox/streets-v9',
  bbox: [[-123.881836, 25.063209], [-65.170898, 48.848451]],
  center: [-95.844727, 39.620499],
  zoom: 3,
  padding: 30,
  containerStyle: {
    position: 'fixed',
    top: 0,
    left: 0,
    right: 0,
    bottom: 0,
    zIndex: 1
  }
}

const ExampleMap = () => {
  return (
    <MapboxProvider accessToken='[your token]'>
      <MapGL {...mapOptions}>
        {/* Source to be used by layers (U.S. state polygons) */}
        <Source
          id='states'
          type='geojson'
          data='https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_110m_admin_1_states_provinces.geojson'
        />

        {/* State fill layer */}
        <Layer
          id='states-fill'
          source='states'
          type='fill'
          paint={{
            'fill-color': '#627BC1',
            'fill-opacity': 0.5
          }}
        />

        {/* State borders layer */}
        <Layer
          id='states-borders'
          source='states'
          type='line'
          paint={{
            'line-color': '#627BC1',
            'line-width': 2
          }}
        />

        {/* Declarative handler for hovering a layer's features.

            This component optionally allows a function as the
            *children*, similar to how libraries like react-motion do. You can
            leverage that to filter layers or otherwise modify them.

            The *property* should be a member of `feature.properties` that
            uniquely identifies each feature.
        */}
        <Hover layer='states-fill' property='name'>
          {({properties: names}) => (
            <Layer
              id='states-hover'
              source='states'
              type='fill'
              paint={{
                'fill-color': '#627BC1',
                'fill-opacity': 1
              }}
              filter={[
                '==',
                'name',
                names[0] || ''
              ]}
            />
          )}
        </Hover>
      </MapGL>
    </MapboxProvider>
  )
}

export default ExampleMap

Developed by TerraEclipse

Terra Eclipse, Inc. is a nationally recognized political technology and strategy firm located in Santa Cruz, CA and Washington, D.C.

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].