update doc

This commit is contained in:
Andy Gup 2015-05-29 15:12:40 -06:00
parent 42e49f137a
commit 9f68a46fe4
2 changed files with 62 additions and 16 deletions

View File

@ -77,25 +77,14 @@ NOTE: You can also monitor standard ArcGIS API for JavaScript layer events using
**Step 4** After the `layers-add-result` event fires extend the feature layer using the `extend()` method.
Optionally, if you are building a fully offline app then you will also need to set the `dataStore` property in the constructor if you want full control of what is stored. You can also access an automatically created data store via the `getFeatureCollections()` method. If you use the `getFeatureCollections()` pattern you can simply ignore the `dataStore` property in the constructor. Here is an example of the Object returned in the `getFeatureCollections()` callback:
Optionally, if you are building a fully offline app then you will also need to set the `dataStore` property in the constructor if you want full control of what is stored. Alternatively, you can access an automatically created data store via the `getFeatureCollections()` method. If you use the `getFeatureCollections()` pattern you can simply ignore the `dataStore` property in the constructor.
```js
{
id: "feature-collection-object-1001",
featureLayerCollections: [
{
featureLayerUrl: "http://...",
featureLayerCollection: { . . . }
}
]
}
```
The `featureLayerCollection` is equivalent to `featureLayer.toJson()`.
The library's internal `featureLayerCollection` is equivalent to `featureLayer.toJson()`.
Note: the `layer.extend()` callback only indicates that the edits database has been successfully initialized.
Here is an example of initializing the library for partial offline use. Note that the `dataStore` property is not set because it's only needed if you need to restart the browser while offline.
```js
function initEditor(evt)
@ -114,6 +103,27 @@ Note: the `layer.extend()` callback only indicates that the edits database has b
```
For full offline use, the pattern would look like this where we are creating a `dataStore`.
```js
function initEditor(evt)
{
// OPTIONAL - for fully offline use you can store a data object
// var options = {};
// options.graphics = JSON.stringify(layer1.toJson());
// options.zoom = map.getZoom();
offlineFeaturesManager.extend(layer1,function(success, error){
if(success){
console.log("layer1 has been extended for offline use.");
}
}, dataStore);
}
```
When working with fully offline browser restarts you should wait until the layer has been successfully extended before forcing the library to go back online. The workflow for this coding pattern is you start out online > offline > browser restart > then back online.
```js
@ -177,7 +187,26 @@ You can then retrieve this data after an offline restart by using the following
```
If you don't want to deal with creating and managing your own data store when working with offline browser restarts, then here's the pattern for using the built-in `featureLayerCollections`. This pattern is ideal if you are using Esri's pre-built widgets such as `AttributeInspector` and you don't have access to the necessary events for creating and updating the `dataStore`.
If you don't want to deal with creating and managing your own data store when working with offline browser restarts, then here's the pattern for using the built-in `featureLayerCollections`. This pattern is ideal if you are using Esri's pre-built widgets such as `AttributeInspector` and you don't have access to the necessary events for creating and updating the `dataStore`.
Once you set `ENABLED_FEATURECOLLECTION` to `true` the library will automatically update its internal snapshot of the feature layer every time an ADD, UPDATE or DELETE is executed while offline.
```js
// Tell the library to automatically create and store a snapshot of the
// of the feature layer.
offlineFeaturesManager.ENABLE_FEATURECOLLECTION = true
offlineFeaturesManager.extend(layer1,function(success, error){
if(success){
console.log("layer1 has been extended for offline use.");
}
});
```
Now you can use this pattern to reconstitute the layer after an offline browser restart:
```js
@ -199,6 +228,22 @@ If you don't want to deal with creating and managing your own data store when wo
```
Here is an example of the Object returned in the `getFeatureCollections()` callback:
```js
{
id: "feature-collection-object-1001",
featureLayerCollections: [
{
featureLayerUrl: "http://...",
featureLayerCollection: { . . . }
}
]
}
```
**Step 5** Once a layer has been extended the offline library will enable it with new methods. Here are a few examples that include code snippets of how to take advantage of some of the library's methods. You can also use a combination of methods from `editsStore` and `offlineFeaturesManager`.
####offlineFeaturesManager.proxyPath

View File

@ -20,6 +20,7 @@ Property | Value | Description
`ATTACHMENTS_DB_OBJECTSTORE_NAME` | "attachments" | (Added @ v2.7) Sets the attachments database object store name.
`proxyPath` | null | Default is `null`. If you are using a Feature Service that is not CORS-enabled then you will need to set this path.
`attachmentsStore` | null | Default is `null`. If you are using attachments, this property gives you access to the associated database.
`ENABLE_FEATURECOLLECTION` | `false` | Enabling this property will allow the library to create a snapshot of the feature layer and make it available via `getFeatureCollections()`. When you extend a layer and you want to use a custom `dataStore` then leave this property set to `false` so that you don't end up with two copies of the feature layer in the database.
###ENUMs
The manager can be in one of these three states (see `getOnlineStatus()` method):