Loading map in background thread

38 views
Skip to first unread message

Jaroslav

unread,
Feb 20, 2012, 10:11:43 AM2/20/12
to route-me
I'm using offline maps from sqlite database and loading 100Mb of maps
takes several seconds. How could I kame view controller visible with
some type of indicator while view controller is loading map? I tried
using
[self performSelectorInBackground:@selector(loadMap) withObject:nil];
in viewDidLoad and then in loadMap
[self performSelectorOnMainThread:@selector(showMap) withObject:nil
waitUntilDone:NO];
with
- (void) showMap{
self.view = mapView;
}

Map seems to be loaded but I doesn't get displayed until I exit from
this view controller and go back to it again.

Maybe someone came to solution how to show user that map is currently
loading?



Justin R. Miller

unread,
Feb 21, 2012, 3:00:08 PM2/21/12
to route-me
It seems suspect to me that your map is taking several seconds to
load. What kind of SQLite backend are you using? Is it indexed
properly?

--
Justin R. Miller
Development Seed, Inc.
jus...@developmentseed.org

Jaroslav Ozevič

unread,
Feb 21, 2012, 3:07:55 PM2/21/12
to route-...@googlegroups.com
I created maps from tiles (downloaded from OSM) using osm2mbtiles
program (https://github.com/rpcarver/osm2mbtiles). It gave me 100mb
sqlite file.
Then I use RMMBTilesTileSource as a tile source. (RMMBTilesTileSource
*source = [[RMMBTilesTileSource alloc] initWithTileSetURL:tilesURL]; )
Thats it :)

Maybe I should add some indexes manually?

> --
> You received this message because you are subscribed to the Google Groups "route-me" group.
> To post to this group, send email to route-...@googlegroups.com.
> To unsubscribe from this group, send email to route-me-map...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/route-me-map?hl=en.
>

--
Pagarbiai,
Jaroslav Ozevič,
+37065350120
http://www.linkedin.com/in/jaroslavozevic

Jaroslav Oo

unread,
Feb 21, 2012, 3:13:04 PM2/21/12
to route-...@googlegroups.com
Checked it now: tiles able has one index: zoom_level,tile_column,tile_row


On Feb 20, 7:11 am, Jaroslav <jaroslav.oze...@gmail.com> wrote:
> I'm using offline maps from sqlite database and loading 100Mb of maps
> takes several seconds. How could I kame view controller visible with
> some type of indicator while view controller is loading map? I tried
> using
> [self performSelectorInBackground:@selector(loadMap) withObject:nil];
> in viewDidLoad and then in loadMap
> [self performSelectorOnMainThread:@selector(showMap) withObject:nil
> waitUntilDone:NO];
> with
> - (void) showMap{
> self.view = mapView;
>
> }
>
> Map seems to be loaded but I doesn't get displayed until I exit from
> this view controller and go back to it again.
>
> Maybe someone came to solution how to show user that map is currently
> loading?

Justin R. Miller

unread,
Feb 22, 2012, 1:25:17 PM2/22/12
to route-me
That was just a hunch -- things sound ok. FWIW I have used 1GB+
MBTiles databases before without this kind of delay. Maybe profile
your app with Instruments and see where it is spending its time?

--
Justin R. Miller
Development Seed, Inc.
jus...@developmentseed.org

> > For more options, visit this group athttp://groups.google.com/group/route-me-map?hl=en.
Reply all
Reply to author
Forward
0 new messages