Giter Site home page Giter Site logo

lkazberova / react-mapbox-gl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alex3165/react-mapbox-gl

0.0 2.0 0.0 11.76 MB

A React binding of mapbox-gl-js

Home Page: http://alex3165.github.io/react-mapbox-gl/

License: MIT License

JavaScript 1.09% HTML 0.77% TypeScript 94.20% CSS 3.77% Shell 0.17%

react-mapbox-gl's Introduction

Logo

React-mapbox-gl Doc

Build Status npm version npm downloads



London cycle example gif

React wrapper for mapbox-gl-js. Expose a bunch of component meant to be simple to use for React. It is important to understand the difference between the components Map, Layer, GeoJsonLayer, Source, Feature (proxy between React and Mapbox API) and the components Marker, Popup, Cluster, ZoomControl, ScaleControl, RotationControl which are real React components.

Include the following elements:

  • ReactMapboxGl
  • Layer
  • Source
  • Feature
    • Layer type properties symbol display a mapbox symbol.
    • Layer type properties line display a lineString.
    • Layer type properties fill display a polygon.
    • Layer type properties circle display a mapbox circle.
  • GeoJSONLayer
  • ZoomControl
  • ScaleControl
  • RotationControl
  • Marker (Projected component)
  • Popup (Projected component)
  • Cluster

This repository include the Typescript type definition files

How to start

npm install react-mapbox-gl mapbox-gl --save

Example:

// ES6
import ReactMapboxGl, { Layer, Feature } from "react-mapbox-gl";

// ES5
var ReactMapboxGl = require("react-mapbox-gl");
var Layer = ReactMapboxGl.Layer;
var Feature = ReactMapboxGl.Feature;

const Map = ReactMapboxGl({
  accessToken: "pk.eyJ1IjoiZmFicmljOCIsImEiOiJjaWc5aTV1ZzUwMDJwdzJrb2w0dXRmc2d0In0.p6GGlfyV-WksaDV_KdN27A"
});

<Map
  style="mapbox://styles/mapbox/streets-v9"
  containerStyle={{
    height: "100vh",
    width: "100vw"
  }}>
    <Layer
      type="symbol"
      id="marker"
      layout={{ "icon-image": "marker-15" }}>
      <Feature coordinates={[-0.481747846041145, 51.3233379650232]}/>
    </Layer>
</Map>

Why is zoom an array

The zoom property is an array on purpose. With a float as a value we can't tell whether the zoom has changed when checking for value equality 7 === 7 // true. We changed it to an array so that between 2 render it check for a reference equality [7] === [7] // false, this way we can reliably update the zoom value without having to keep the viewport in the state of the Map component.

Contributions

Built with react-mapbox-gl

monumap.org

mapbox-gl-draw compatibility

Try react-mapbox-gl-draw

react-mapbox-gl's People

Contributors

0x7b1 avatar alex3165 avatar arthur31416 avatar bjorkstam avatar cmrtn avatar daniel5151 avatar faiq avatar greenkeeper[bot] avatar hobofan avatar itjope avatar jluxenberg avatar joshwcomeau avatar jpdevries avatar jthetzel avatar kitten avatar kmamykin avatar lamuertepeluda avatar lastsys avatar laznic avatar lkazberova avatar marek-sed avatar mollymerp avatar mtauer avatar nbadag avatar rlski avatar sbrk avatar sohibul avatar tsemerad avatar wykks avatar z0d14c avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.