Map API

MGMaps Lib SDK is professional toolkit to develop mobile mapping applications.
Platforms: iPhone, Android, RIM BlackBerry, Java ME (J2ME)
Download maps API SDK »
Untitled Document

Products

Latest news

Last at Mon, 6 Sep 2010 12:27:06
Topic: Let your feedback ideas flow
See more news »

Nutiteq on Twitter

11 weeks 6 days ago Nutiteq is proud sponsor of StateOfTheMap 2010 #sotm10

Android Download Map Tiles

3 replies [Last post]
xger86x
User offline. Last seen 23 weeks 1 day ago. Offline
Joined: 02/11/2010

Hi,

i have a question. Is it possible downloading Open Street Map tiles while i'm showing the map to the user in the device? Because i want to have the maps offline but i don't know what map is going to need the user until he choose a city.

Thanks

jaak
User offline. Last seen 2 days 1 hour ago. Offline
Joined: 06/19/2008

I do not get fully what you want to get. Perhaps you should download tiles in parallel with map showing inside the application. Library does not have specific downloader for this.

You can also define permanent cache to the SD card, so next time map does not need to be downloaded.

/JaakL

xger86x
User offline. Last seen 23 weeks 1 day ago. Offline
Joined: 02/11/2010

Yes, that is what i want, but i don't really know how can i tell to the Nutiteq Map that it must use the downloaded tiles in the SDCard instead downloading them.

Thanks

jaak
User offline. Last seen 2 days 1 hour ago. Offline
Joined: 06/19/2008

Following code controls also that not too much
of space is taken for the cache:

     final MemoryCache memoryCache = new MemoryCache(1 * 1024 * 1024); // 1MB

            // final File cacheDir = this.getCacheDir(); // maybe it is not safe to use it
            final File cacheDir = new File("/sdcard/maps_lib_cache");
            if (!cacheDir.exists()) {
                cacheDir.mkdir();
            }
            if(cacheDir.exists()){
            StatFs statFs = new StatFs(cacheDir.getAbsolutePath());
            int freespace = statFs.getAvailableBlocks() * statFs.getBlockSize();

            Log.debug("Free space of " + cacheDir.getAbsolutePath() + " is "
                    + freespace);

            int cacheSizeWish = 10 * 1024 * 1024; // 10 MB

            // do not take more than 50% of free space for caches
            int cacheSize = (cacheSizeWish * 2) >= freespace ? (int) freespace / 2
                    : cacheSizeWish;

            Log.debug("File cache set to  " + cacheSize);

            final AndroidFileSystemCache fileSystemCache = new AndroidFileSystemCache(
                    this, "network_cache", cacheDir, cacheSize);
            
            mapComponent.setNetworkCache(new CachingChain(new Cache[] {
                    memoryCache, fileSystemCache }));
            }else{
                mapComponent.setNetworkCache(new CachingChain(new Cache[] {
                        memoryCache}));
            }

/JaakL