Esri / offline-editor-js

ArcGIS JavaScript library for handling offline editing and tiling.
http://esri.github.io/offline-editor-js/demo/
Apache License 2.0
159 stars 142 forks source link

Editing not working with full browser restart #437

Closed tjones0808 closed 6 years ago

tjones0808 commented 8 years ago

I have implemented the offline functionality with no problems when using the partial editing offline solutions. I can go offline cut all internet make edits, come back online and everything works fine. The problems arise when restarting the browser. For some reason it seems the extending isn't working, when trying to make any edits, nothing happens. I see an attempting progress bar on the editor widget but then it just quits

Code that inits layers:

function extendFeatureLayer(featureLayer, online, callback) {

    var dataStore = {};
    dataStore.featureLayerCollection = JSON.stringify(featureLayer.toJson());
    dataStore.zoomLevel = _map.getZoom();
    dataStore.centerPt = (_map.extent.getCenter()).toJson();
    dataStore.featureLayerUrl = featureLayer.url;
    dataStoreArray.push(dataStore);

    offlineEdit.extend(featureLayer, function (result, error) {
        if (result) {
            // If the app is online then force OfflineEditAdvanced to its online state
            // This will force the library to check for pending edits and attempt to
            // resend them to the Feature Service.
            if (_isOnline) {
                goOnline();
            }
            else {
                goOffline();
                updateStatus("Successfully extended layer for offline use.");
            }

            callback(true);
        }
        else {
            callback(false);
            alert("Unable to initialize the database. " + error);
        }

    }.bind(this), dataStoreArray);
}

function loadFeatureLayerOffline(callback) {
    offlineEdit.getFeatureLayerJSONDataStore(function (success, dataStore) {
        if(success){

            // Use the feature layer returns from getFeatureDefinition() to reconstitute the layer
            // We don't have to set any other properties on the layer because we are using it
            // in SNAPSHOT mode which downloads all features within the given extent.
            array.forEach(dataStore, function (ds) {
                featureLayer = new FeatureLayer(JSON.parse(ds.featureLayerCollection));

                //if (featureLayer.url == undefined) {
                    featureLayer.url = ds.featureLayerUrl;
                    featureLayer._url = {
                        path: ds.featureLayerUrl,
                        query: null
                    }
                //}

                featureLayerArray.push(featureLayer);                    
                dataStore = getFeatureLayerJSON(featureLayer);

            });

            on(_map, 'layers-add-result', extendOffline);

            console.log("Feature has been added back to the map while offline.");                           

            _map.centerAt(dataStore.centerPt);
            _map.setZoom(dataStore.zoomLevel);

            callback(true);
        }
        else {
            updateStatus("There was a problem retrieving feature layer options object. " + dataStore);
            callback(false);
        }
    });
}

function extendOffline() {
    array.forEach(featureLayerArray, function (featureLayer) {
        extendFeatureLayer(featureLayer, _isOnline, function (success) {
            updateStatus("Feature Layer extended successfully OFFLINE!");
        });
    });
}

function getFeatureLayerJSON(featureLayer) {
    return {
        "featureLayerCollection": JSON.stringify(featureLayer.toJson()),
        "zoomLevel": _map.getZoom(),
        "centerPt": (_map.extent.getCenter()).toJson(),
        "featureLayerUrl": featureLayer.url
    }
}

function updateFeatureLayerJSON() {

    array.forEach(featureLayerArray, function (featureLayer) {
        var fl = getFeatureLayerJSON(featureLayer);

        featureLayer.setFeatureLayerJSONDataStore(fl, function (result, error) {
            console.log('updateFeatureLayerJson - Result: ' + result + ", error: " + error);
        });
    });        
}

function initPanZoomListeners() {        

    _map.on("zoom-end", function (evt) {
        _currentExtent = evt.extent;
        updateFeatureLayerJSON();
    });

    _map.on("pan-end", function (evt) {
        _currentExtent = evt.extent;
        updateFeatureLayerJSON();
    });
}

    initMap: function () {
        if (has('phone') && !this.config.mapOptions.infoWindow) {
            this.config.mapOptions.infoWindow = new PopupMobile(null, put('div'));
        }
        this.map = new Map('mapCenter', this.config.mapOptions);
        _map = this.map;

        // initalize offline module and settings
        var initFunc = lang.hitch(this, 'initOfflineEdits');
        initFunc();

        if (this.config.mapOptions.basemap) {
            this.map.on('load', lang.hitch(this, 'initLayers'));
        } else {
            this.initLayers();
        }
        if (this.config.operationalLayers && this.config.operationalLayers.length > 0) {
            if (_isOnline) {
                on(this.map, 'layers-add-result', lang.hitch(this, 'layersAddedEvent'));
            } else {
                var initEvent = lang.hitch(this, 'layersAddedEvent');
                initEvent();
            }
        } else {
            this.initWidgets();
        }
    },
    layersAddedEvent: function (evt) {

        var initWidgets = lang.hitch(this, 'initWidgets');
        initWidgets();
        var me = this;

        //on.once(this.map, 'update-end', lang.hitch(me, 'initFeaturesListener'));

        if (evt) {
            array.forEach(evt.layers, function (layerObj) {

                var type = layerObj.layer.type;

                if (type === "Feature Layer") {
                    var fl = layerObj.layer;
                    featureLayerArray.push(fl);
                    on.once(fl, 'update-end', lang.hitch(me, 'initFeaturesListener', fl));  
                }
            })
            me.initOfflineTiles(me.map);                
        } else {
            me.initOfflineTiles(me.map);

            var initFeatsOffline = lang.hitch(me, 'initFeaturesListener');
            initFeatsOffline();
        }
    },      
    initFeaturesListener: function (fl) {  
        // If app is online then we ONLY need to extend the feature layer.
        if (_isOnline) {
            extendFeatureLayer(fl, _isOnline, function (success) {
                if (success) {
                    initPanZoomListeners();
                }
                else {
                    updateStatus("There was a problem initializing the map for offline.");
                }
            });                 
        }
            // If the app is offline then we need to retrieve the dataStore from OfflineEditAdvanced
            // and then extend the feature layer using that information.
        else {
            loadFeatureLayerOffline(function (success) {
                if (success) {

                    _map.addLayers(featureLayerArray);
                }
                else {
                    updateStatus("There was a problem initializing the map for offline.");
                }
            });
        }
    },
    initFeaturesOfflineListener: function (featureLayer) {
        extendFeatureLayer(featureLayer, _isOnline, function (success) {
            initPanZoomListeners();
            updateStatus("Feature Layer extended successfully OFFLINE!");
        });                         
    },
    initOfflineEdits: function () {
        offlineEdit = new O.esri.Edit.OfflineEditAdvanced();

        // pull this from config

        //offlineEdit.ENABLE_FEATURECOLLECTION = true;

        offlineEdit.initAttachments(function (success) {
            //attachmentsInited = success;
        });

        offlineEdit.on(offlineEdit.events.EDITS_ENQUEUED, updateQuedStatus);
        offlineEdit.on(offlineEdit.events.EDITS_SENT, updateStatus);
        offlineEdit.on(offlineEdit.events.ALL_EDITS_SENT, updateStatus);
        offlineEdit.on(offlineEdit.events.EDITS_SENT_ERROR, editsError);
        offlineEdit.on(offlineEdit.events.EDITS_ENQUEUED_ERROR, editsError);

    },

    initLayer: function (layer, Layer) {
        var l = new Layer(layer.url, layer.options);
        this.layers.unshift(l); //unshift instead of push to keep layer ordering on map intact
        //Legend LayerInfos array
        var excludeLayerFromLegend = false;
        if ( typeof layer.legendLayerInfos !== 'undefined' && typeof layer.legendLayerInfos.exclude !== 'undefined' ) {
            excludeLayerFromLegend = layer.legendLayerInfos.exclude;
        }
        if ( !excludeLayerFromLegend ) {
            var configuredLayerInfo = {};
            if ( typeof layer.legendLayerInfos !== 'undefined' && typeof layer.legendLayerInfos.layerInfo !== 'undefined' ) {
                configuredLayerInfo = layer.legendLayerInfos.layerInfo;
            }
            var layerInfo = lang.mixin( {
                layer: l,
                title: layer.title || null
            }, configuredLayerInfo );
            this.legendLayerInfos.unshift ( layerInfo ); //unshift instead of push to keep layer ordering in legend intact
        }
        //LayerControl LayerInfos array
        this.layerControlLayerInfos.unshift({ //unshift instead of push to keep layer ordering in LayerControl intact
            layer: l,
            type: layer.type,
            title: layer.title,
            controlOptions: layer.layerControlLayerInfos
        });
        if (layer.type === 'feature') {
            var options = {
                featureLayer: l
            };
            if (layer.editorLayerInfos) {
                lang.mixin(options, layer.editorLayerInfos);
            }
            if (options.exclude !== true) {
                this.editorLayerInfos.push(options);
            }
        }
        if (layer.type === 'dynamic' || layer.type === 'feature') {
            var idOptions = {
                layer: l,
                title: layer.title
            };
            if (layer.identifyLayerInfos) {
                lang.mixin(idOptions, layer.identifyLayerInfos);
            }
            if (idOptions.exclude !== true) {
                this.identifyLayerInfos.push(idOptions);
            }
        }
    },
andygup commented 8 years ago

@tjones0808 Can you paste the console.log here from an offline restart? Lets see if there are any errors.

andygup commented 8 years ago

I see a number of errors. You can ignore the ones stating ERR_NAME_NOT_RESOLVED, but any other errors such as dojo.io.script error Error(…) or XMLHttpRequest cannot load indicate there is a problem.

The following error tells me you'll need a proxy or you'll need to set up CORS on the gis.aoscloud.net server:

 XMLHttpRequest cannot load https://gis.aoscloud.net/gissandbox/rest/info?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://localhost:44300' is therefore not allowed access.

Recommendation 2 is to fix the HTTPS Mixed Content error and host tiny-image.png on your own server.

 Mixed Content: The page at 'https://localhost:44300/viewer/index.html' was loaded over HTTPS, but requested an insecure image 'http://esri.github.io/offline-editor-js/tiny-image.png?_=152282965'. This content should also be served over HTTPS.
andygup commented 8 years ago

Oh wait, I may have misunderstood. You are talking about when the app comes back up after an offline restart.

Is your Application Cache set up correctly?

Can you paste a screenshot of your console log when the application first loads?

andygup commented 8 years ago

This may be related to https://github.com/Esri/offline-editor-js/issues/434. In general, the Editor Widget isn't supported for this library since it's not compliant with full offline requirements. That's why the appcache-features.html sample uses a custom-built editor widget that is fully offline capable. I'll dig a bit deeper and see what I can find.

andygup commented 8 years ago

Just to clarify the Editor Widget is supported by OfflineEditBasic and not supported by OfflineEditAdvanced when using it for full offline. If there is something in OfflineEditAdvanced I can tweak then I'll certainly do that. I'll let you know.

tjones0808 commented 8 years ago

Ok, I didn't know that because in your documentation that is not specified. It says for OfflineEditBasic: "This library is optimized for Partial Offline Support ONLY".

tjones0808 commented 8 years ago

Where does it say it supports the Editor Widget?

andygup commented 8 years ago

I'll add a TODO to clarify that in the Limitations section of the README. I've been tackling Editor Widget issues on a case-by-case issue. Unfortunately, since most of the problems I've seen involved proprietary code and/or were not documented here on github as an issue, it's not clear what the exact nature of the issues were or any potential workarounds.

andygup commented 8 years ago

@tjones0808 Have you tried to fix the obvious code errors? For example, https://gis.aoscloud.net/gissandbox/rest/info?f=json needs to be added to your Application Cache:

XMLHttpRequest cannot load https://gis.aoscloud.net/gissandbox/rest/info?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://localhost:44300' is therefore not allowed access.
tjones0808 commented 8 years ago

Yes I have. That url IS added to the appcache and I DO have a proxy setup. For some reason just that URL gets blocked. I was able to workaround the problem by changing how I configured the Editor Widget settings when recreating the featureLayers offline. It seems when I recreate my layers offline they don't get recreated exactly the same so I have to do some manual tweaking. Now my problem is when restarting offline, the editor will open up and edit any feature...but it is not calling apply edits anymore. Will keep chugging along until I have a full fix.

webmapsolutions commented 8 years ago

Just a quick addition here. We have been working with the library for some time. Those using it will naturally turn to the Editor Widget first. The widget is a black box at the minute (since not open sourced). We asked for it to be open sourced in ideas.esri.com last year. Our focus is full offline not partial. We have extended one of Andy's samples so we can test (in a simple environment) full offline using the Editor Widget. We think we have isolated an issue #434 whether this is a library issue or Editor Widget issue we are unsure. Regardless, we would like to find if the Editor Widget is or is not causing problems in full offline mode, and update the docs with what is found.

On 6 January 2016 at 07:22, tjones0808 notifications@github.com wrote:

Yes I have. That url IS added to the appcache and I DO have a proxy setup. For some reason just that URL gets blocked. I was able to workaround the problem by changing how I configured the Editor Widget settings when recreating the featureLayers offline. It seems when I recreate my layers offline they don't get recreated exactly the same so I have to do some manual tweaking. Now my problem is when restarting offline, the editor will open up and edit any feature...but it is not calling apply edits anymore. Will keep chugging along until I have a full fix.

— Reply to this email directly or view it on GitHub https://github.com/Esri/offline-editor-js/issues/437#issuecomment-169334355 .

Matt Sheehan | WebMapSolutions

Mobile: 801-733-0723 | Email: matt@webmapsolutions.com Email%3Amatt@webmapsolutions.com

tjones0808 commented 8 years ago

The editor widget IS causing problems for full offline, when the featureLayers are reconstituted the editor widget doesn't play well with them. When we go to an offline state from an online state, the editor widget works perfectly and saves all edits and re-syncs them no problem. I am looking more into the specific problem today of why starting in an offline state the editor widget doesn't cooperate, but I've had to make changes to the way the editor widget creates and updates features and how it calls the applyEdits function.

webmapsolutions commented 8 years ago

It sounds like we need a generic custom editor widget added to the library (or at least extended version of Andy's sample). Most who are interested in using the library will we think want full offline capabilities, and naturally turn to the Editor Widget. If that is not an option it will put many off going further with the library.

On 6 January 2016 at 08:11, tjones0808 notifications@github.com wrote:

The editor widget IS causing problems for full offline, when the featureLayers are reconstituted the editor widget doesn't play well with them. When we go to an offline state from an online state, the editor widget works perfectly and saves all edits and re-syncs them no problem. I am looking more into the specific problem today of why starting in an offline state the editor widget doesn't cooperate, but I've had to make changes to the way the editor widget creates and updates features and how it calls the applyEdits function.

— Reply to this email directly or view it on GitHub https://github.com/Esri/offline-editor-js/issues/437#issuecomment-169348890 .

Matt Sheehan | WebMapSolutions

Mobile: 801-733-0723 | Email: matt@webmapsolutions.com Email%3Amatt@webmapsolutions.com

tjones0808 commented 8 years ago

I agree. I will post what I find when I have it fully working.

webmapsolutions commented 8 years ago

Excellent as will I from the testing we are doing.

On 6 January 2016 at 08:31, tjones0808 notifications@github.com wrote:

I agree. I will post what I find when I have it fully working.

— Reply to this email directly or view it on GitHub https://github.com/Esri/offline-editor-js/issues/437#issuecomment-169358783 .

Matt Sheehan | WebMapSolutions

Mobile: 801-733-0723 | Email: matt@webmapsolutions.com Email%3Amatt@webmapsolutions.com

andygup commented 8 years ago

Thanks for the input and the effort, it's much appreciated!

FWIW, the Editor Widget (JS API v3.x) is great for laptops and tablets, but doesn't work well on smartphones. There are folks who have built custom, focused editing functionality that fits well into a mobile, responsive application. I've also referred a number of folks to this mobile attribute editing sample.

webmapsolutions commented 8 years ago

That is very cool Andy. If we could roll a sample into the library (maybe using this code as a base) it would be a great jumpstart for others.

On 6 January 2016 at 08:49, Andy notifications@github.com wrote:

Thanks for the input and the effort, it's much appreciated!

FWIW, the Editor Widget (JS API v3.x) is great for laptops and tablets, but doesn't work well on smartphones. There are folks who have built custom, focused editing functionality that fits well into a mobile, responsive application. I've also referred a number of folks to this mobile attribute editing https://developers.arcgis.com/javascript/jssamples/mobile_citizenrequest.html sample.

— Reply to this email directly or view it on GitHub https://github.com/Esri/offline-editor-js/issues/437#issuecomment-169364159 .

Matt Sheehan | WebMapSolutions

Mobile: 801-733-0723 | Email: matt@webmapsolutions.com Email%3Amatt@webmapsolutions.com

andygup commented 8 years ago

@tjones0808 @webmapsolutions Another note, I've long suspect that theEditor Widget issue is related to the FeatureLayer.toJson() functionality. The OfflineEditAdvanced library uses that when converting the current feature layer into a featureCollection for storage in the database.

It's a fact that the toJson() method does NOT do a 1:1 conversion and that's caused other issues, such as #280, when reconstituting feature layers. I wouldn't be surprised if there is something missing that's important to the Editor Widget. If we can narrow that piece down it might be something that can be programmatically added to the library.

tjones0808 commented 8 years ago

Yes, I have to manually correct the featureLayer.id and featureLayer._outFields to even get the editor to open up and edit the correct attributes. Trying to figure out why now it wont call applyEdits after offline restart.

webmapsolutions commented 8 years ago

Take a look at this sample it might help:

http://webmapsolutions.com/offline-editor-v3/samples/appcache-twofeatureslayer-edit-wms.html

It works end to end for editing using Editor Widget in full offline mode. Applyedits functions correctly. The issue we are finding is rendering a new point (added in full offline) after a full offline reload.

On 6 January 2016 at 09:11, tjones0808 notifications@github.com wrote:

Yes, I have to manually correct the featureLayer.id and featureLayer._outFields to even get the editor to open up and edit the correct attributes. Trying to figure out why now it wont call applyEdits after offline restart.

— Reply to this email directly or view it on GitHub https://github.com/Esri/offline-editor-js/issues/437#issuecomment-169372532 .

Matt Sheehan | WebMapSolutions

Mobile: 801-733-0723 | Email: matt@webmapsolutions.com Email%3Amatt@webmapsolutions.com

tjones0808 commented 8 years ago

@webmapsolutions your having the same problem I did. When you restart offline your editor doesn't let you edit the attributes. It pops up and seems like it works... but the attributes dont show up.

offlinesampleerror

andygup commented 8 years ago

Yep, I talked to @webmapsolutions earlier today. I think the consensus now is that FeatureLayer.toJson() is, in fact, missing certain properties. Once we've identified all of them, we'll need to verify "if" they can be stringified or not.

Just thinking out loud: If it can't be stringified we can then attempt to store them as their native ArcGIS JS API objects. IndexedDB uses a structured clone algorithm to serialize complex JavaScript objects. The caveat is it the algorithm sometimes balks if it detects recursion or deep nested functions. Mozilla does offer sample code showing how to do a deep copy that we could always try if we run into problems.

andygup commented 8 years ago

@tjones0808 @webmapsolutions please review this and let me know your thoughts?

Conclusion: the default Editor Widget will not work for offline restarts.

I took a deep look into why the graphics aren't showing up after an offline restart. The Editor Widget uses map.graphics instead of the FeatureLayer.graphics. OfflineEditAdvanced extends FeatureLayer and uses FeatureLayer.graphics. So, anything stored in map.graphics gets blow away during the browser restart process, the new feature you created won't get displayed.

The Editor Widget also does not provide any hooks into public events were you might be able to copy new features from the widget to FeatureLayer.graphics.

Recommended approach: Build custom, focused editing functionality that applies ADD operations directly to FeatureLayer.graphics.

The Editor Widget is a one-size-fits-all approach. It's a swiss army knife of editing so it wouldn't make any sense to reproduce all of its functionality for the purposes of this repo.

As I mentioned above, the mobile attribute editor sample seems like it will fit the bill for this. When offline, you'd need to make sure any new graphics were added to FeatureLayer.graphics before calling FeatureLayer.applyEdits().

Option A: I could build a small sample demonstrating how to do an ADD feature. This is the most obvious solution.

Option B: I could create a heavily modified and redacted version of the mobile attribute editor sample that fits the purposes of this repo. That would take a while.

Option C:??

webmapsolutions commented 8 years ago

Great work Andy. The mystery revealed. Having a sample custom editor included in the library, I think would be huge particularly as the library gets more attention this year from the wider community (which it will given the increasing realisation of the importance of offline). That means B above. Given your workload Andy are we talking late Spring here? Just wondering how we might be able to help (divide and conquer)?

On 8 January 2016 at 09:59, Andy notifications@github.com wrote:

@tjones0808 https://github.com/tjones0808 @webmapsolutions https://github.com/webmapsolutions please review this and let me know your thoughts?

Conclusion: the default Editor Widget will not work for offline restarts.

I took a deep look into why the graphics aren't showing up after an offline restart. The Editor Widget uses map.graphics instead of the FeatureLayer.graphics. OfflineEditAdvanced extends FeatureLayer and uses FeatureLayer.graphics. So, anything stored in map.graphics gets blow away during the browser restart process, the new feature you created won't get displayed.

The Editor Widget also does not provide any hooks into public events were you might be able to copy new features from the widget to FeatureLayer.graphics.

Recommended approach: Build custom, focused editing functionality that applies ADD operations directly to FeatureLayer.graphics.

The Editor Widget is a one-size-fits-all approach. It's a swiss army knife of editing so it wouldn't make any sense to reproduce all of its functionality for the purposes of this repo.

As I mentioned above, the mobile attribute editor https://developers.arcgis.com/javascript/jssamples/mobile_citizenrequest.html sample seems like it will fit the bill for this. When offline, you'd need to make sure any new graphics were added to FeatureLayer.graphics before calling FeatureLayer.applyEdits().

Option A: I could build a small sample demonstrating how to do an ADD feature. This is the most obvious solution.

Option B: I could create a heavily modified and redacted version of the mobile attribute editor sample that fits the purposes of this repo. That would take a while.

Option C:??

— Reply to this email directly or view it on GitHub https://github.com/Esri/offline-editor-js/issues/437#issuecomment-170055190 .

Matt Sheehan | WebMapSolutions

Mobile: 801-733-0723 | Email: matt@webmapsolutions.com Email%3Amatt@webmapsolutions.com

andygup commented 8 years ago

Thanks. I'll take a close(r) look at the sample today and take a first stab at outlining the TODO tasks. That will give me a much better feel for the work involved. Sound cool?

webmapsolutions commented 8 years ago

Sounds great Andy. Let us know where/if we can help with some of these tasks. Thx

On 8 January 2016 at 10:42, Andy notifications@github.com wrote:

Thanks. I'll take a close(r) look at the sample today and take a first stab at outline the TODO tasks. That will give me a much better feel for the work involved. Sound cool?

— Reply to this email directly or view it on GitHub https://github.com/Esri/offline-editor-js/issues/437#issuecomment-170070044 .

Matt Sheehan | WebMapSolutions

Mobile: 801-733-0723 | Email: matt@webmapsolutions.com Email%3Amatt@webmapsolutions.com

andygup commented 8 years ago

Will do. I'll post the TODO list.

andygup commented 8 years ago

Here's the TODOs for the mobile editor sample. Next week I'll create a branch on my own repo and share that. Once it's up we can start chipping away at it.

Because it's a small project, we'll need to be careful to not step on each others work. My recommendation will be that we post comments directly in the branch's commit page to ask questions and for you to verify before working on a particular item.

  1. Remove geocoder code and css - won't work offline
  2. Move css to external file to allow compression and minification
  3. Remove map switcher code and css
  4. Look into modularizing the feature ADD page
  5. Find anything else that can be squashed
  6. Update jQuery, jQuery Mobile
  7. The feature attribute view page needs to respect cycling thru multiple features
  8. Create new optimized version of JS API library that supports this app
  9. Update cache manifest
  10. Build in the offline functionality
andygup commented 8 years ago

@webmapsolutions @tjones0808 here's the working branch for the sample-in-progress.

The new sample is currently called appcache-features-edit. If you are looking to tackle one of the TODOs above or something I missed, just let me know beforehand. That way we can avoid duplication of effort.

I'll be addressing number 3 and 4 today.

andygup commented 8 years ago

Forgot to mention: please add comments related to the sample app directly in-line to the 3.1 branch. That way we can focus the message traffic and not bombard everyone else.

webmapsolutions commented 8 years ago

Sounds good. Thanks Andy.

On 11 January 2016 at 12:12, Andy notifications@github.com wrote:

Forgot to mention: please add comments related to the sample app directly in-line to the 3.1 branch. That way we can focus the message traffic and not bombard everyone else.

— Reply to this email directly or view it on GitHub https://github.com/Esri/offline-editor-js/issues/437#issuecomment-170656416 .

Matt Sheehan | WebMapSolutions

Mobile: 801-733-0723 | Email: matt@webmapsolutions.com Email%3Amatt@webmapsolutions.com

webmapsolutions commented 8 years ago

@tjones0808 https://github.com/tjones0808 A quick note here. Our work is focused around offline enabling Universal Map Viewer. We have gone a long way down this path. Looking at the code posted it looks like you are attempting something similar. Happy to compare notes.

On 8 January 2016 at 09:59, Andy notifications@github.com wrote:

@tjones0808 https://github.com/tjones0808 @webmapsolutions https://github.com/webmapsolutions please review this and let me know your thoughts?

Conclusion: the default Editor Widget will not work for offline restarts.

I took a deep look into why the graphics aren't showing up after an offline restart. The Editor Widget uses map.graphics instead of the FeatureLayer.graphics. OfflineEditAdvanced extends FeatureLayer and uses FeatureLayer.graphics. So, anything stored in map.graphics gets blow away during the browser restart process, the new feature you created won't get displayed.

The Editor Widget also does not provide any hooks into public events were you might be able to copy new features from the widget to FeatureLayer.graphics.

Recommended approach: Build custom, focused editing functionality that applies ADD operations directly to FeatureLayer.graphics.

The Editor Widget is a one-size-fits-all approach. It's a swiss army knife of editing so it wouldn't make any sense to reproduce all of its functionality for the purposes of this repo.

As I mentioned above, the mobile attribute editor https://developers.arcgis.com/javascript/jssamples/mobile_citizenrequest.html sample seems like it will fit the bill for this. When offline, you'd need to make sure any new graphics were added to FeatureLayer.graphics before calling FeatureLayer.applyEdits().

Option A: I could build a small sample demonstrating how to do an ADD feature. This is the most obvious solution.

Option B: I could create a heavily modified and redacted version of the mobile attribute editor sample that fits the purposes of this repo. That would take a while.

Option C:??

— Reply to this email directly or view it on GitHub https://github.com/Esri/offline-editor-js/issues/437#issuecomment-170055190 .

Matt Sheehan | WebMapSolutions

Mobile: 801-733-0723 | Email: matt@webmapsolutions.com Email%3Amatt@webmapsolutions.com

webmapsolutions commented 8 years ago

@tjones0808 https://github.com/tjones0808 sorry my last entry should have read Configurable Map Viewer.

On 14 January 2016 at 12:00, Matt Sheehan matt@webmapsolutions.com wrote:

@tjones0808 https://github.com/tjones0808 A quick note here. Our work is focused around offline enabling Universal Map Viewer. We have gone a long way down this path. Looking at the code posted it looks like you are attempting something similar. Happy to compare notes.

On 8 January 2016 at 09:59, Andy notifications@github.com wrote:

@tjones0808 https://github.com/tjones0808 @webmapsolutions https://github.com/webmapsolutions please review this and let me know your thoughts?

Conclusion: the default Editor Widget will not work for offline restarts.

I took a deep look into why the graphics aren't showing up after an offline restart. The Editor Widget uses map.graphics instead of the FeatureLayer.graphics. OfflineEditAdvanced extends FeatureLayer and uses FeatureLayer.graphics. So, anything stored in map.graphics gets blow away during the browser restart process, the new feature you created won't get displayed.

The Editor Widget also does not provide any hooks into public events were you might be able to copy new features from the widget to FeatureLayer.graphics.

Recommended approach: Build custom, focused editing functionality that applies ADD operations directly to FeatureLayer.graphics.

The Editor Widget is a one-size-fits-all approach. It's a swiss army knife of editing so it wouldn't make any sense to reproduce all of its functionality for the purposes of this repo.

As I mentioned above, the mobile attribute editor https://developers.arcgis.com/javascript/jssamples/mobile_citizenrequest.html sample seems like it will fit the bill for this. When offline, you'd need to make sure any new graphics were added to FeatureLayer.graphics before calling FeatureLayer.applyEdits().

Option A: I could build a small sample demonstrating how to do an ADD feature. This is the most obvious solution.

Option B: I could create a heavily modified and redacted version of the mobile attribute editor sample that fits the purposes of this repo. That would take a while.

Option C:??

— Reply to this email directly or view it on GitHub https://github.com/Esri/offline-editor-js/issues/437#issuecomment-170055190 .

Matt Sheehan | WebMapSolutions

Mobile: 801-733-0723 | Email: matt@webmapsolutions.com Email%3Amatt@webmapsolutions.com

Matt Sheehan | WebMapSolutions

Mobile: 801-733-0723 | Email: matt@webmapsolutions.com Email%3Amatt@webmapsolutions.com

tjones0808 commented 8 years ago

hey thanks @webmapsolutions , i was consulting for a company and they halted the project on Monday. As soon as it starts back up I will continue work on the offline editor. Really appreciate the help though!

andygup commented 6 years ago

Closing.