A Few Questions About MapKit

Discussion in 'iOS Programming' started by Darkroom, Oct 3, 2009.

  1. Darkroom Guest


    Dec 15, 2006
    Montréal, Canada
    1. Is it possible to contain an MKMapView within certain coordinates? perhaps by programatically shifting (bounce back) the view when a boundary is reached?

    2. For offline support, is it possible to save/refer to an MKMapView within certain coordinates?
  2. Kingbombs macrumors member

    Jun 24, 2009
    2. yes you can save co-ordinates and then display them even when offline (although you won't be able to get the person's current position, unless GPS is working, im assuming by offline you meant no GPS)

    1. Yes you can make sure the MKMapView will only view a certain part of the map, and you can get it to zoom to a certain distance as well
    Although i am not 100% sure if you can only make it bounce back when they have moved X distance away i haven't personally tried that
  3. Darkroom thread starter Guest


    Dec 15, 2006
    Montréal, Canada
    sorry, my second question was more referencing the ability to actually view the map when offline. if i turn off wifi on my iPod touch the map isn't saved, and doesn't reload - i get grid lines only. is there a way to force-cache, or save a map (EX: the city of Montréal, from 4 corner coordinates or something like that) for viewing offline?


    oh... and one more question to add to my list:

    3. i've set the image property of the MKAnnotationView to replace the default pin annotations with my own image. however, canShowCallout is also set to yes, and while the map loads with my custom annotations, whenever i tap to show a callout, the image of the annotation i've tapped changes into a pin. i haven't yet tried to actually subclass MKPinAnnotationView, and currently believe that is why this is happening, but if that's the case, what's the purpose of the image property?

    MKAnnotationView *annotationView = [self.myMapView dequeueReusableAnnotationViewWithIdentifier:@"AnnotationID"];
    if (annotationView == nil)
    	annotationView = [[[MKPinAnnotationView alloc] initWithAnnotation:annot reuseIdentifier:@"AnnotationID"] autorelease];
    	annotationView.image = [UIImage imageNamed:@"customPin.png"];
    	annotationView.canShowCallout = YES;
    return annotationView;
    [EDIT Again] ah, the image property only works in the subclass... clearly... :rolleyes:
  4. tcarcur macrumors newbie

    Jan 16, 2008
    Wirelessly posted (iPhone: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7C144 Safari/528.16)

    You cannot request mapkit to cache something.

    What gets cached is anything the user has seen on the Maps app, your app, or any other app that has mapkit.
  5. tigermain macrumors newbie

    Apr 2, 2009
    What did you mean by this? How did you solve this problem, Im having the same issue

    Update: I worked out what you mean, this code should help someone:

    UIImage * image = [UIImage imageNamed:mad:"blue_pin.png"];
    UIImageView *imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
    [annView addSubview:imageView];

Share This Page