Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MapTypeStyle in MapKit

I wonder to know if there is any way to configure our MapKit maps like we do with the MapTypeStyle object in the Google Maps API.

If I refer to Apple doc's, MKMapView has a mapType option that takes MKMapType constant but no styles parameters like MapOptions with the MapTypeStyle and the MapTypeStyler wich is very powerfull for fast maps customizing.

So my question is : Is there any way to achieve something similar with the MapKit framework, if not, what is the best framework/library to do this ? I'm thinking of MapBox and similar products.

like image 674
rayfranco Avatar asked Apr 27 '12 17:04

rayfranco


2 Answers

There are a few options for you my friend. You could use one of these frameworks

http://cloudmade.com/products/iphone-sdk

https://github.com/route-me/route-me

Or you could just use mapbox. Their api looks pretty good. Alternatively you supply you own map tiles and overlay mapkit. Something like this in a MKOverlayView

- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {

NSURL* fileURL = [(HeatMap*)self.overlay localUrlForStyle:@"alien" withMapRect:mapRect andZoomScale:zoomScale];
NSData *imageData = [NSData dataWithContentsOfURL:fileURL ];
if (imageData != nil) {
    UIImage* img = [UIImage imageNamed:@"aTileX.png"];
    // Perform the image render on the current UI context
    UIGraphicsPushContext(context);
    [img drawInRect:[self rectForMapRect:mapRect] blendMode:kCGBlendModeNormal alpha:1.0];
    UIGraphicsPopContext();
    }
}

Also check this out if you want unsupported "terrain" mode http://openradar.appspot.com/9621632

I'm actually in the middle of a program that requires overlaying tiles over a map. This example has been very helpful. You'll want to look into MKOverlay and MKOverlayView. The project that I am doing involves using gheat. I am accessing the tiles through an NSURLConnection and storing them locally. A gist of my implementation.

like image 162
Rich86man Avatar answered Oct 17 '22 01:10

Rich86man


There is no way to customize the map styles natively with mapkit. Your only option for this is to opt for a hybrid app approach, and then customize the styles using html/javascript in the page itself.

like image 2
jdb1a1 Avatar answered Oct 17 '22 03:10

jdb1a1