Coder Social home page Coder Social logo

ol-react's Introduction

A thin wrapper for OpenLayers3 in React.

The goal is to be able to write applications using OpenLayers maps in a declarative way. For example, the following is JSX, which can be returned by the render() method on a React component, to generate a map with a red square near the equator.

<Map view=<View resolution={10000} center={[0, 0]}/>>
  <layer.Tile>
    <source.OSM />
  </layer.Tile>
  <layer.Vector>
    <source.Vector>
      <Feature style={{stroke: {color: [255, 0, 0, 1]}}}>
        <geom.LineString>
          {[[0, 0], [100000, 0], [100000, 100000], [0, 100000]]}
        </geom.LineString>
      </Feature>
    </source.Vector>
  </layer.Vector>
</Map>

To understand what each element does, read the OpenLayers API documentation.

Styles

Are declared using a JSON object, passing through the properties you'd like on the final object.

When creating an Icon, Circle or RegularShape, a type parameter must be present, with the value of icon, circle, or regular-shape.

Example:

image: {
    type: 'circle',
    radius: 10,
    fill: { color: '#666666' },
    stroke: { color: '#bada55', width: 1 }
}

It's early days! If you're familiar with react and/or openlayers and are interested in helping, please get in touch. Available on github and npm.

I am especially interested in assistance with having each component be optionally controlled. This would allow binding of the components with, say, Redux and for sophisticated state management outside of OpenLayers.

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.