Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/remotestorage/remoteStorage.locations
remoteStorage.js module for points in space
https://github.com/remotestorage/remoteStorage.locations
Last synced: 5 days ago
JSON representation
remoteStorage.js module for points in space
- Host: GitHub
- URL: https://github.com/remotestorage/remoteStorage.locations
- Owner: remotestorage
- Created: 2013-02-07T16:13:05.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-02-08T12:33:58.000Z (over 11 years ago)
- Last Synced: 2024-08-01T12:36:06.022Z (3 months ago)
- Language: JavaScript
- Size: 111 KB
- Stars: 4
- Watchers: 7
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-starred - remotestorage/remoteStorage.locations - remoteStorage.js module for points in space (others)
README
# remoteStorage.locations
This module stores [GeoJSON](http://www.geojson.org/geojson-spec.html) Features and Feature Collections.
## Usage
index.html:
```html
```
app.js:
```javascript
// claim read-write access to 'locations'
remoteStorage.claimAccess('locations', 'rw').
then(function() {
// initialize 'locations' module
remoteStorage.locations.init();
// display widget
remoteStorage.displayWidget();
});
```### Adding a Collection
```javascript
remoteStorage.locations.addCollection('my-collection').
then(function() {
console.log('collection created!');
});
```### Removing a Collection
```javascript
remoteStorage.locations.removeCollection('my-collection').
then(function() {
console.log('collection removed!');
});
```### Getting a Collection, managing Features
```javascript
remoteStorage.locations.getCollection('my-collection').
then(function(collection) {
// the collection will be yielded, no matter if it existed before.
// as soon as a feature is added, the collection would be created.// Features can be listed ...
collection.getFeatures().
then(function(features) {
console.log("Features: ", JSON.stringify(features));
});// ... and added
collection.addFeature({
// 'type' and 'id' for the feature will be added automatically, like:
//type: 'Feature',
//id: Math.uuid(),
geometry: {
type: 'Point',
coordinates: [-150.08093299249254, 0.3955046715318032]
},
properties: {
title: 'Water',
description: 'Marks location of some water.'
}
});});
```### Events
The following events are emitted by remoteStorage.locations:
* `add-collection`
* `remove-collection`
* `update-collection`
* `add-feature`
* `remove-feature`
* `update-feature`All these events yield an 'event' object like the one described [here in the remoteStorage.js documentation](http://remotestoragejs.com/doc/code/files/lib/baseClient-js.html#BaseClient.change).
## Contributing
If you have any suggestions, questions or additions, please open up an issue, fork the project & send pull requests and / or drop by our IRC channel **#remotestorage** on **irc.freenode.org**.