Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-03-2012, 05:08 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 31
Wikiboo is on a distinguished road
Default Adding multiple annotations to iPhone MapView is slow

I have code that takes a title and an address of a location,then get coordinates from google maps csv, then add annotation. It works, but when I want to add 50 or more annotation at once it freezes for about 30-40 seconds and then displays annotations or ot just crashes, so what I want to know is did I screw up memory management and that's why it's so slow, or something else?

Here is the code:
Code:
- (void) addAnnotation: (NSString*) annoTitle: (NSString*) annoAddress
{
    NSString *address = annoAddress;

    NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", [address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
    NSArray *listItems = [locationString componentsSeparatedByString:@","];

    float langcoord = [[listItems objectAtIndex:2] floatValue];
    float longcoord = [[listItems objectAtIndex:3] floatValue];

    CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(langcoord, longcoord);

    // Create an instance of MapPoint with the current data
    Annotation *annotation = [[Annotation alloc] initWithCoordinate:coord title:annoTitle];

    // Add it to the map view
    [mapView addAnnotation:annotation];

    // MKMapView retains its annotations, so we can release it
    [annotation release];
}
Wikiboo is offline   Reply With Quote
Old 01-03-2012, 08:09 AM   #2 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 158
cribasoft is on a distinguished road
Default

Are you sure its not the internet call-out to Google that is slow?

I bet the rest of that code in your pasted block executes in 0.01% of the time it takes to make that one call to ...contentsOfUrl.

Try hard-coding that call -- put a string in there that you know will work and then run your code. I bet it is fast as lightning without that internet call. Plus you are blocking the UI thread with that internet call -- you should never do that as your users will 1-star you OR worse, iOS will decide the app is hung and kill your process.

You'll need to find a better way to do that. Maybe you can do them all at once using an operation queue and add them to the map as each call returns... or something like that.
cribasoft is offline   Reply With Quote
Old 01-03-2012, 09:11 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 202
not_too_shabby is on a distinguished road
Default

Have you tried the forward geocaching methods in iOS5? I have just started using them and they seem pretty fast. You might try that as well to see if the speed issue is coming from google.
not_too_shabby is offline   Reply With Quote
Old 01-24-2012, 09:16 AM   #4 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 31
Wikiboo is on a distinguished road
Default

Quote:
Originally Posted by not_too_shabby View Post
Have you tried the forward geocaching methods in iOS5? I have just started using them and they seem pretty fast. You might try that as well to see if the speed issue is coming from google.
Link please?
Wikiboo is offline   Reply With Quote
Old 01-24-2012, 09:24 AM   #5 (permalink)
Registered Member
 
apatsufas's Avatar
 
Join Date: Jan 2011
Location: Thessaloniki, Greece
Posts: 121
apatsufas is on a distinguished road
Default

Documentation for the new CLGeocoder here

Sample app GeocoderDemo here
__________________
SQLed - Your Database Manager on the go

iAZConverter - Converts everything from A to Z
apatsufas is offline   Reply With Quote
Old 01-24-2012, 10:34 AM   #6 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by apatsufas View Post
Documentation for the new CLGeocoder here

Sample app GeocoderDemo here
Documentation? What is this "documentation" of which you speak?
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 01-24-2012, 10:44 AM   #7 (permalink)
Registered Member
 
apatsufas's Avatar
 
Join Date: Jan 2011
Location: Thessaloniki, Greece
Posts: 121
apatsufas is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
Documentation? What is this "documentation" of which you speak?
__________________
SQLed - Your Database Manager on the go

iAZConverter - Converts everything from A to Z
apatsufas is offline   Reply With Quote
Old 01-26-2012, 12:34 PM   #8 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 4
Ricardogilson is on a distinguished road
Default

This site can help you!
Ricardogilson is offline   Reply With Quote
Reply

Bookmarks

Tags
annotations, crash, iphone, mapview, multiple

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 399
12 members and 387 guests
buggen, EvilElf, guusleijsten, j.b.rajesh@gmail.com, LunarMoon, morterbaher, QuantumDoja, sacha1996, Sami Gh, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,673
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, morterbaher
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:32 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0