Saving image data using web storage

262 views
Skip to first unread message

afnan...@gmail.com

unread,
Apr 10, 2013, 3:58:33 AM4/10/13
to cesiu...@googlegroups.com
Hey everyone!

So I forked/cloned cesium and started working on implementing offline support for tiles loaded into the map. I have implemented offline support for metadata which comes from Bingmaps.

Now I'm working on saving images into browser storage.

Would it be a good idea to stick the images inside an HTML5 Canvas element and using toDataURL to get the data from the image and storing it as JSON inside web storage? (ref: https://developer.mozilla.org/en-US/docs/DOM/HTMLCanvasElement)

If not, is there something else anyone would like to suggest?

Here's my github clone, for reference: https://github.com/afahim/cesium

Tom Payne

unread,
Apr 10, 2013, 12:50:20 PM4/10/13
to cesiu...@googlegroups.com

Hi,

OpenLayers 2 has some support for storing tiles offline:

  https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Control/CacheRead.js

However, most browser local storage is limited to about 5MB, which means you can't store many tiles in it. At Camptocamp we're using Cordova (formally PhoneGap) to build a native application as a workaround this limitation.

Regards,

Tom


--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Scott Hunter

unread,
Apr 10, 2013, 4:25:46 PM4/10/13
to cesiu...@googlegroups.com
Tom, 

Have you looked into the Quota Management APIs for OpenLayers at all?  https://developers.google.com/chrome/whitepapers/storage#persistent  It may only be implemented in Chrome so far, but the general user experience seems ideal, in that the user has the chance to agree to allocate arbitrary amounts of disk space for storage.  A prompt for the user would also help avoid abuse like http://feross.org/fill-disk/.

Scott

afnan...@gmail.com

unread,
Apr 10, 2013, 10:49:38 PM4/10/13
to cesiu...@googlegroups.com
Tom,

Thanks for the suggestion. That helped me in figuring out how to store tiles.

Scott,

I read the different API's on html5rocks and it seems like a combination of FileSystem API and Quota Management API would be a good idea in order to store large amounts of data, but the solution would only work on Chrome. Also, Quota Management is an experimental API and thus implementation might need to be changed later on in case some other standard is adopted. But for now, it seems like a good idea to go ahead with implementation based on these technologies.

Best,
Reply all
Reply to author
Forward
0 new messages