offline-editor-js
A prototype JavaScript toolkit for using the ArcGIS API for JavaScript offline. It offers both lightweight editing and tile management capabilities while offline or intermittently offline. It's still a work-in-progress so if you have suggestions open an issue or if you want to make a pull request we welcome your proposed modifications.
IMPORTANT: If you want a fully integrated robust offline solution then you should be using our ArcGIS Runtime SDKs for .NET, WPF, Java, iOS, Android and Qt.
This repo contains the following libraries:
/dist:offline-edit-min.js- (replaces v1.x of OfflineFeaturesManager.js) stores adds, updates and deletes of features as well as limited attachment support while offline. Resync's edits with server once connection is reestablished.offline-tiles-basic-min.js- (replaces v1.x of offlineTilesEnabler.js) stores portions of tiled maps client-side and uses the cached tiles when device is offline or partial offline. Use this library with ArcGIS Online Web maps.offline-tiles-advanced-min.js- (replaces v1.x of OfflineTilesEnablerLayer.js) Extends any ArcGIS Tiled Map Service that has a requirement for offline browser reload and/or restart. This library should be used in conjunction with an HTML5 application cache coding pattern.offline-tpk-min.js- (replaces v1.x of TPKLayer.js) parses a TPK file and displays it as a tiled map layer.
/utils: contains various helper library modules./samples: samples that show how to use the different offline libraries capabilities.
#Workflows Supported The following workflow is currently supported for both both features and tiles:
-
Load web application while online.
-
Once all tiles and features are loaded then programmatically take application offline.
-
Make edits while offline.
-
Return online when you want to resync edits.
Using an application manifest allows you to reload and restart the application while offline. The application manifest lets you store .html, .js, .css and image files locally.
Attachment Support: Attachments are supported with some limitations. See documentation here
#API Doc
##Offline Editing of Geographic Features Extends and overrides an ArcGIS Feature Layer. This library allows you to extend esri.layers.FeatureLayer with offline capabilities and to manage the resync process.
- Click here to see the full API doc for
offline-edit-min.js
##Offline Mapping Tiles Extends and overrides a tiled map service. Provides the ability to customize the extent used to cut the tiles. See the detailed description of basemap.prepareForOffline() in the "How To Use" section to learn different options.
- Click here to see the full API doc for
offline-tiles-basic-min.js and offline-tiles-advanced-min.js
##TPKLayer
You can display TPK files with this library. TPK's are binary tile package files. Extends TileMapServiceLayer. Go here for more information on how to create a TPK file.
- Click here to see the full API doc for
offline-tpk-min.js
#How to use
- Learn more about using the
tilelibrary - Learn more about using the
editlibrary - Learn more about using the
tpklibrary - Learn more about using an application cache with this library
##Setup Instructions
- Fork and clone the repo.
- After cloning from github,
cdinto theoffline-editor-jsfolder - Run
git submodule initandgit submodule update - Try out the apps in the
/samplesfolder.
If you need to build the libraries:
- From the root directory run
npm install - Run
Grunt build. If there are no errors, the minimized (min) and source (src) versions of the libraries will be output to\dist
##Samples
appcache-features.html- shows how to work with the application manifest, tiles and features.appcache-tiles.html- shows how to work with the application manifest and map tiles.attachments-editor.html- demonstrates how to work with this library using feature attachments.draw-pointlinepoly-offline.htmlshows working with points, lines and polygons locally.tpklayer.html- shows how to work with TPK files.tiles-indexed-db.html- shows how to work with storing tiles locally.Gruntfile.js- a node.js app and its associatedpackage.jsonfile to help with creating an application manifest file.
##Dependencies
-
ArcGIS API for JavaScript (v3.8+)
-
NOTE: browser limitations and technical dependencies. The offline capabilities in this toolkit depend on certain HTML5 capabilities being present in the browser. Go here for a detailed breakdown of the information.
-
We offer browser support for Chrome and Safari only, at this time. Some of the capabilities in the repository will not work on Internet Explorer. We continue to evaluate IE's capabilities as new releases become available to try and identify a point where we might be able to support it.
-
Sub-modules (see
/vendordirectory)- offline.js - it allows detection of the online/offline condition and provides events to hook callbacks on when this condition changes
- IndexedDBShim - polyfill to simulate indexedDB functionality in browsers/platforms where it is not supported (notably desktop Safari and iOS Safari)
- IMPORTANT: There are known issues with IndexedDBShim on Safari. For Safari, the storage error workaround is to switch from using /dist/IndexedDBShim.min.js to just using IndexedDBShim.js and then search for and modify the line that defines the value for
DEFAULT_DB_SIZE. Set this to more appropriate size that will meet all your storage needs, for example:var DEFAULT_DB_SIZE = 24 * 1024 * 1024
- IMPORTANT: There are known issues with IndexedDBShim on Safari. For Safari, the storage error workaround is to switch from using /dist/IndexedDBShim.min.js to just using IndexedDBShim.js and then search for and modify the line that defines the value for
- jasmine.async - library to help implementing tests of async functionality (used in tests)
-
Non sub-module based libraries
- FileSaver.js - library to assist with uploading and downloading of files containing tile information.
- grunt-manifest node.js library to assist with the creation of manifest files.
- zip A library for zipping and unzipping files.
- xml2json A library for converting XML to JSON. Seems to handle complex XML.
Resources
Issues
Find a bug or want to request a new feature? Please let us know by submitting an issue.
Contributing
Anyone and everyone is welcome to contribute. Please see our guidelines for contributing.
Licensing
Copyright 2014 Esri
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
A copy of the license is available in the repository's license.txt file.
[](Esri Tags: ArcGIS Web Mapping Editing FeatureServices Offline) [](Esri Language: JavaScript)