moagrius / MapView

(Deprecated, prefer https://github.com/moagrius/TileView) Android widget roughly described as a hybrid between com.google.android.maps.MapView and iOS's CATiledLayer
http://moagrius.github.com/MapView/documentation
69 stars 35 forks source link

Loading tiles from http #31

Closed mohlendo closed 11 years ago

mohlendo commented 11 years ago

I would like to load the tiles from web and not from the filesystem. Would it be possible to do that? Would it be enough to change the implementation of https://github.com/moagrius/MapView/blob/master/src/com/qozix/mapview/tiles/MapTile.java#L107 ?

moagrius commented 11 years ago

Yes, that method (decode) is where the bitmap is retrieved. This happens in a background thread in an AyncTask (https://github.com/moagrius/MapView/blob/master/src/com/qozix/mapview/tiles/TileManager.java#L261), which is published to the UI thread when complete, so in theory you should be able to run the http request in the decode method without any other updates. I'd be very interested to hear how it turns out, and see a sample in action, if it works and you wouldn't mind posting back.

mohlendo commented 11 years ago

This commit in my fork https://github.com/mohlendo/MapView/commit/9842191fd09a99d3fef6457195aad5605b4d8277 shows how to load tiles from server. In that version you can provide a protocol in the file pattern like

mapView.addZoomLevel(1024, 1024, "http://localhost:8080/tiles/256/0/%col%-%row%.png", 256, 256);

and the MapView loads them over http. If you provide no protocol, it loads the files as assets. Now it would be possible to add more protocol implementations like ftp etc...

Should I create a pull request in order to integrate that?

mohlendo commented 11 years ago

If have created a pull request now. So we can close this here and discuss the pull request.