From 1778bb917ea23e41e8b9e9007bf26ad6c033e403 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 25 Sep 2017 23:30:38 -0700 Subject: [PATCH] Destroyed Minimal Vector API (markdown) --- Minimal-Vector-API.md | 70 ------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 Minimal-Vector-API.md diff --git a/Minimal-Vector-API.md b/Minimal-Vector-API.md deleted file mode 100644 index 05348e7..0000000 --- a/Minimal-Vector-API.md +++ /dev/null @@ -1,70 +0,0 @@ -## Goals - -* provide a way to fetch vector data from multiple sources, in multiple formats -* provide a way to style the data for rendering -* provide a way to edit the data -* provide a way to persist edits - -## Fetch Vector Data - -The vector source can fetch data and persist edits (like the protocol in OpenLayers 2). HTTP can be the default, and there can be other vector sources (e.g. WFS). We can start with a default fixed strategy, and later we can add more strategies. So the minimal API for fetching vector data could look like this: - -```js -var layer = new ol.layer.Vector({ - style: myStyle, - source: new ol.source.Vector({ - url: 'http://example.com/data', - projection: 'remote-proj', // this will typically come with the data - parser: new ol.parser.GeoJSON() - }) -}); -``` - -For data that is already available in memory as string or object, a `data` option can be provided instead of `url`. - -Notes and questions from @elemoine: - -So ol.layer.Vector works with a fixed strategy, an HTTP protocol, and a GeoJSON format (using ol2 terms here). What would the API look like if what I want to use is a fixed strategy and, say, a WFS protocol? - -What do we fix in a source type? The strategy? The protocol? Both? I think I would fix the strategy, and get rid of strategies entirely in ol3. - -So: - -```js -var layer = new ol.layer.Vector({ - style: myStyle, - source: new ol.source.VectorFixed({ - protocol: new ol.protocol.WFS({ - url: 'http://example.com/data', - parser: new ol.parser.GeoJSON() - }) - }) -}); -``` - -For Fixed/HTTP/GeoJSON, Fixed/HTTP/TopoJSON, and Fixed/HTTP/KML we can certainly provide convenience classes: ol.source.GeoJSON, ol.source.TopoJSON, and ol.source.KML. E.g. - -```js -var layer = new ol.layer.Vector({ - style: myStyle, - source: new ol.source.GeoJSON({ - url: 'http://example.com/data' - }) -}); -``` - -## Style Vector Data - -Initially, we can style data with a subset of CartoCSS or SLD, without exposing a style API. - -## Edit Vector Data - -Features can already be accessed with `ol.Map#getFeatures`. [#850](http://github.com/openlayers/ol3/issues/850) adds event handling for added and removed features, so the renderer can keep the view up to date. The CHANGE event could also be used to keep track of feature modifications, but it imposes significant overhead to register a change listener on every single feature. So preferably, the feature modification workflow will be provided by controls that move features to a sketch layer for editing and register CHANGE listeners for these features only. After editing, the sketch features can be moved back to their original layer. This workflow can also be used for attribute modifications. - -## Persist Edits - -The layer source can also provide a way to save changes for protocols that support CRUD. - -## Other Vector Data Interactions - -To zoom to the data extent of a vector layer, OpenLayers 2 had a getDataExtent method on the vector layer. As long as the responsibilities of layer and source are still under discussion, we could expose something like a `ol.Map#zoomToLayer()` method, which could be implemented for all layer types, and would use the data extent of a vector layer with a fixed strategy.