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

Bing maps support? #453

Closed humzaak closed 8 years ago

humzaak commented 8 years ago

The prepareForOffline function does not cache the correct tiles when applying it to Bing maps. How should I go about changing the library code to work with Bing maps?

andygup commented 8 years ago

Hi, I don't know since I don't work with Bing maps. You need to research and compare how a Bing map service works to how an Esri map service works. If there are only simple differences then it may be an easy fix, if there are major differences then it may not be worth your while.

At the most basic level, a map service has to use the following convention in order to work with this library:

http:// <mapservice-url>/tile/<level>/<row>/<column>
humzaak commented 8 years ago

i have changed this convention in the library to make it work with bing maps. the map shows up and zooms in and out ok, but when i try to download it, the downloaded data is always of different extent then the one selected. I believe that it is a coordinate issue.

andygup commented 8 years ago

@humzaak do you have a link to the Bing maps protocol documentation? Any REST request + error info you can share?

humzaak commented 8 years ago

@andygup This is the best explanation of bing maps tiling scheme out there in my opinion. I am not getting any error. The tiles are downloading fine, its just that they are from a different extent then the one I select for download. I just made small changes in offline-tiles-basic-src.js so far and this allowed me to display bing maps and estimate cache size from it using offline-editor.js Tiles Only sample :

  1. Commented line 123
  2. Commented line 794

Also commented line 423-425 in simple-tiles.html sample, replaced the web map id with an id containing bing map layer I made using ArcGIS online, provided a bing map key in createMap function and that was it.

The console window shows the tiles being created and their urls are valid, its just that they are not what I intend them to be.

image

andygup commented 8 years ago

Based on your console.log screenshot, I don't believe it's possible to make this work without a significant rewrite. It looks like the Bing tile requests are not using the convention that the library requires:

http:// <mapservice-url>/tile/<level>/<row>/<column>
humzaak commented 8 years ago

I am attaching a csv file here that I generated from the library just now after making the 3 4 small changes which I mentioned in my previous post. As you can see in the file, we can download the bing tiles (both url and the data), hence proving that it works, the problem is that I panned my map to Asia, Europe, Africa and Australia continent and the library downloaded the whole world extent for zoom level 1 and 2.

Bing_Tiles.txt

andygup commented 8 years ago

we can download the bing tiles (both url and the data), hence proving that it works,

It's only partially working while online, because as you said the extents are incorrect. Did you test that the tiles still work correctly when the application is offline?

It's not clear to me exactly what is being stored in the database.

humzaak commented 8 years ago

It is partially working offline (screenshots attached), but some tiles are always missing. Also I have attached database storage screenshot as well. image image

andygup commented 8 years ago

Thanks for the screenshots, that helped. The tile library is definitely not working correctly.

What I suspect you need to do is re-write the library so that it works with VETileLayer. The current library was built to only support ArcGISTiledMapServiceLayer and related layers that use a /level/row/column URI protocol. This hasn't been documented clearly and I'm happy to add clarification to the documentation.

humzaak commented 8 years ago

Thanks. I will try rewriting the library. The thing that was getting me confused for some hours is that if the original library is hooked up to only support ArcGISTiledMapServiceLayer, then why is it even partially performing the following functions for VETileLayers ?

  1. Estimating tile count and size
  2. Downloading and storing the tiles
  3. Showing up tiles while offline

All of these tasks are performed partially by the library for VETiledLayers but they are still being performed to some extent. This made me initially believe that a only few changes in the code can make this library support Bing Maps.

andygup commented 8 years ago

Yes, I was very surprised it sort of worked. In theory, it should have failed outright. But, without having access to the code it's hard to say. Somehow, the Bing Maps request tricked it.

Here's an example of a valid URI:

"http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/16/24711/32092"

And, here's an example of a valid img and url properties:

img:"/9j/4AAQSkZJRgA...XoK002Jsya38Q31tw4DknqwxihpCP//ZAA=="
url:"http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/16/24711/32092"
humzaak commented 8 years ago

The code is still the same what you have on github. I only commented out 5 lines from your code and got these results. I did not add any line to the original code

offline-tiles-basic-src.js : commented lines no. 123 and 794 simple-tiles.html : commented lines no. 423-425

andygup commented 8 years ago

@humzaak Any luck on this?

humzaak commented 8 years ago

@andygup sorry none so far. I have stopped working on it for a while and currently only working with ESRI maps.I will come back to this in about a month.

andygup commented 8 years ago

@humzaak I'm going to close this out. If anything else comes up feel free to reopen as necessary.