Package Exports
- ol-couchdb-source
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ol-couchdb-source) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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 onhttp://localhost:8080
and a PouchDB (CouchDB compatible) in memory server athttp://localhost:3000/_utils
.npm run deploy
- Compiles your application to the lib folder.