How to use Offline Cloudmade Maps in an iPhone App - iphone

I’ve looked through the posts on the Cloudmade site here and I get some of it, but not all. I've posted the question below, but haven't had the help I need, so I thought I'd ask the question here.
I can see that I need to:
download the tiles for the required area to my Mac (but can’t see how to do this)
convert these to a sqlite database using the map2sqlite utility, changing the code to output the tiles to a table called “ZCACHE”, not “tiles”
Copy the DB to the Application Bundle
insert some code to copy this DB on first run, from the Application Bundle to the Documents Directory
Somehow get App to use this DB and not an online one – I can’t see how that’s done.
Any help would be warmly welcomed,
Chris.

The best solution for me to have iPhone offline maps is:
1.- Generate your own maps with TileMill and then export to MBTiles format.
2.- Get the mbtiles-ios-example and use the MBTiles file you just generated. In order to compile it, you need to download Route-Me and add it to the project.
Now, there is another option (not for free): Mapbox.

please check this tutorial, it can help - http://www.gisnotes.com/wordpress/category/sqlite3/.

Related

Use existing offline raster mbtiles to display on mapbox map

I'd like to transition the map in my app from currently Apple-Maps-SDK to Mapbox. My users already downloaded a lot of offline maps into several .mbtiles tiles containing raster data.
My question now is if it's possible to still use those while the user will be transitioning to the new maps? I just don't simply want to delete all offline maps and tell the user that he needs to download everything again right now, but rather give them a time-window to do that...
I was looking at MGLRasterTileSource/MGLSource and thought that I can create a subclass and somehow provide my own data to the map, but this does not seem to be supported. There are no datasource methods on it for that purpose...
Would be great if somebody could point me into the direction on how to archive what I want.
EDIT:
So I thought it might work that way... I migrate my existing raster tiles into a downloaded pack inside the mapbox offline database. So I had a look at the caches.db but at least the data in there is not just a plain png/jpg (tried with the mapbox satellite images, which should be raster).
Cause there is no public interface for getting existing raster-tiles in there, is there?
I've seen an other solution where somebody is hosting a webserver inside the app... but that somehow looks like quite an overkill to me?!?
https://gist.github.com/namannik/3b7c8b69c2d0768d0c2b48d2ed5ff71c

Retrieving updated files from server to replace files on documents folder of an iPhone

Im new to iPhone programming and wanted to see how people have solved this problem:
Ive created my app which will ship with certain pLists and .png files in the main bundle. However, what I want to do is when the app starts up, Id like it to check my server to see if there are updated versions of the files in the documents folder available. If so Id like the app to download those files.
I was wondering if someone can point me to some resources on how to do this? Ive searched online but haven't come up with good hits.
Whats the google key-word for searching this topic anyways?
Thanks a lot
you can use NSUrlRequest to download the files, to move them to the correct place you can use NSFileManager, if you look at the apple docs for both these classes there should be sample code explaining how to copy/save a file from NSData, and also how to download it.
I don't have any example resources of how to do exactly this, though I would probably do something along the lines of onAppLoad checking to see if the content of the application that you want to keep updated is the most recent, and if not, download it.
As for keywords to search I would try something along the lines of "Automatic App Content Updating/Verification" and throw in "iOS/iPhone/iPad" or some similar combination.
I'll do some more poking around and shoot you a comment notification if I find anything worthwhile, and then edit my post with it.

iPhone Simulating App Update at home before going out in the big bad world

this is a follow on from this question and the link given it seems that when an app is updated all of the files in the documents directory are copied into the updated apps documents directory and also anything in Library/Preferences. Whats the best way to simulate this for testing purposes?
Just copy the files in ApplicationSupport/iPhone Simulator etc? or has anyone developped any funky techniques for testing this.
I have created .sqlite file in my application's documents folder and created some dummy entries in my database table.
Now just change you code build new application without changing any of the certificate and profile information load the new application.
Now check for the old database table records. It will be definitely preserve under your Document directory in .sqlite file.
This is what i followed when i want to check it for same thing.
If anyone know better way then please feel free to suggest new things.
Jim.

"Untar" file on iPhone

I'm writing an iPhone app which downloads a tar-gzipped file from a Webserver, then needs to unarchive this file so that it can be copied into the app's Documents folder.
I'm using tar/gzip because I want to download a whole bunch of small files in one HTTP request, to make everything nice and fast.
I've investigated solutions like http://www.feep.net/libtar/, but as a C/Objective-C newb, I can't get any of them to compile for the iPhone platform.
(I felt like I should just be able to do a system call to "tar -zxvf myfile.tar.gz", but it would appear it's not that easy!)
So is there a simple way to just un-tar a file on the iPhone? Or am I going about this all wrong, and is there a better way to do this?
Thanks in advance!
Nik
This blog post should help you:
http://blog.hawkey.org/?p=332
EDIT: Google cache version of the same page which actually links to a forum post here which links to a Google Code project here, containing some code which implements unzipping on iOS.
Here is a light untar library for iOS : https://github.com/mhausherr/Light-Untar-for-iOS
Complete blog post about the solution : http://blog.octo.com/en/untar-on-ios-the-pragmatic-way/
Hope this helps,
Vincent
I took a different approach by building libarchive and bz2lib as a static library for iOS. You can find it here:
http://github.com/davepeck/iOS-libarchive/

How to use Core Data in saving all the details which were stored or displayed in a table view?

I am developing an app which parses an Xml or RSS feeds of a magazine..The thing is I have to include an offline capability,ie save the previous results which were displayed in each cell(similar to the New York times app) and then display the saved ones when there is no network connection..
Please help me with the codewise explanation using Core data as I was suggested to use it for this particular task.
Will be of great help for me..
Looking forward for your replies
Regards and Thanks
Arun
You probably want to start here.
OH Boy... CoreData.
Good bye 3-4 days of learning how this works. You wont regret learning about core data but there is a LOT.
#OhioDude has a great link. You can also.
1. Xcode > file > New Project. Select Navigation Based App, make sure the coredata checkbox is checked. Viola you have a project with all the core data templates.
2. There is other sample code on Apples website.
One of the tricky and cool things about core data is that you if you deploy a new version you have to write a template of how you app is to roll the data into the new structure.
During dev as I am changing the DB structure, I seem to get errors, so I just do a build>clean. And rename the string for the DB file to something new.
Good luck. Otherwise NSUserDefaults will be fine.
Or just learn about PLIST's you can simply serialize a NSDictionarly object into a PLIST and save it to the disk in a few lines of code. SUPER easy and no stuffing around with CoreData.