Git Product home page Git Product logo

ol-couchdb-source's Introduction

ol-couchdb-source

OpenLayers source for fetching and displaying GeoJSON documents from a CouchDB server.

Prerequisites

  • OpenLayers Library for creating interactive maps on the web.
  • CouchDB (or compatible) database server.

CouchDB document format

Documents are expected to be a valid GeoJSON feature.

Example

{
  "_id": "b98c7d39-f556-4ead-ac3a-86133c66978a",
  "_rev": "1-e4774e4ee81042448f007d7d987b99d1",
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Point",
    "coordinates": [
      -27.773437499999996,
      21.94304553343818
    ]
  }
}

Attachments

Attachments will generate a property in the ol.Feature properties object with the filename as the key and the full path to the file as the value.

Installation

npm install notnotse/ol-couchdb-source

Minimal example

Complete example can be found in the examples folder.

import ol from "openlayers"
import { CouchDBVectorSource } from "ol-couchdb-sourc"

const map = new ol.Map({
  layers: [
    new ol.layer.Vector({
      source: CouchDBVectorSource("https://server/database")
    })
  ],
  target: "map",
  view: new ol.View()
})

API

CouchDBVectorSource

CouchDBVectorSource(databaseUrl, opt_options)

Options

Name Type Default Description
dataProjection ol.ProjectionLike undefined Projection of the data we are reading. A projection as ol.proj.Projection or a SRS identifier string
fetch Object undefined Optional options to add to all fetch requests.
replication bool undefined Start live replication.

Example

CouchDBVectorSource("https://localhost:3000/geodata", {
  dataProjection: "EPSG:4326"
})

.update()

Clear all geometries and fetch new data from server.

Example

const couchSource = CouchDBVectorSource("https://localhost:3000/geodata")
couchSource.update()

.replication.start()

Start live replication

Example

const couchSource = CouchDBVectorSource("https://localhost:3000/geodata")
couchSource.replication.start()

.replication.stop()

Stop live replication

Example

const couchSource = CouchDBVectorSource("https://localhost:3000/geodata")
couchSource.replication.stop()

Development

  • npm start - Spins up webpack server on http://localhost:8080 and a PouchDB (CouchDB compatible) in memory server at http://localhost:3000/_utils.
  • npm run deploy- Compiles your application to the lib folder.

ol-couchdb-source's People

Contributors

itjope avatar bobobobo avatar

Watchers

James Cloos 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.