0.2.7 • Published 7 years ago
@lobaro/react-openlayers v0.2.7
react-openlayers
A minimal React wrapper of OpenLayers 3+ written in TypeScript
Install
npm install react-openlayers --save-devUsage
import {
  interaction, layer, custom, control, //name spaces
  Interactions, Overlays, Controls,     //group
  Map, Layers, Overlay, Util    //objects
} from "react-openlayers";Example
    <Map view={{center: [0, 0], zoom: 2}} onClick={showPopup}>
      <Layers>
        <layer.Tile/>
        <layer.Vector source={markers} style={markers.style} zIndex="1" />
      </Layers>
      <Overlays>
        <Overlay 
          ref={comp => this.overlayComp = comp}
          element="#popup" />
      </Overlays>
      <Controls attribution={false} zoom={true}>
        <control.Rotate />
        <control.ScaleLine />
        <control.FullScreen />
        <control.OverviewMap />
        <control.ZoomSlider />
        <control.ZoomToExtent />
        <control.Zoom />
      </Controls>
      <Interactions>
        <interaction.Select style={selectedMarkerStyle} />
        <interaction.Draw source={markers} type='Point' />
        <interaction.Modify features={markers.features} />
      </Interactions>
    </Map>
    <custom.Popup ref={comp => this.popupComp = comp}>
    </custom.Popup>It strictly follows OpenLayers 3+ API documention
About Author
Allen Kim is the creator of ngmap and ng2-map.
If you like this, you may also like geo-coder.
To start
$ git clone https://github.com/allenhwkim/react-openlayers.git
$ cd react-openlayers
$ npm install
$ npm startList of available npm tasks
npm run: List all available tasksnpm start: Runappdirectory for development usingwebpack-dev-serverwith port 9001npm run clean: Remove dist foldernpm run clean:dist: Clean up unnecessary dist folder within dist and app directorynpm run build:umd: Build UMD modulereact-openlayers.umd.jsnpm run build:app: Buildapp/build/app.jsfor runnable examplesnpm run build: Build all(build:ngc, build:umc, build:app, and clean:dist)
