問題描述
我想知道是否有任何方法可以配置我們的 MapKit 地圖,就像我們在 Google Maps API 中使用 MapTypeStyle 對象一樣.
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.
如果我參考 Apple 文檔,MKMapView 有一個 mapType 選項,它采用 MKMapType 常量 但沒有樣式參數,例如帶有 MapTypeStyle 和 MapTypeStyler 對于快速地圖定制來說非常強大.
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.
所以我的問題是:有沒有辦法用 MapKit 框架實現類似的東西,如果沒有,最好的框架/庫是什么?我正在考慮 MapBox 和類似產品.
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.
推薦答案
我的朋友,你有幾個選擇.您可以使用這些框架之一
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
或者你可以只使用 mapbox.他們的 api 看起來很不錯.或者,您提供自己的地圖圖塊和覆蓋地圖套件.MKOverlayView 中的類似內容
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();
}
}
如果你想要不受支持的地形"模式,也可以看看這個http://openradar.appspot.com/9621632
Also check this out if you want unsupported "terrain" mode http://openradar.appspot.com/9621632
實際上,我正在執行一個需要在地圖上疊加圖塊的程序.這個例子很有幫助.您需要查看 MKOverlay 和 MKOverlayView.我正在做的項目涉及使用 gheat.我正在通過 NSURLConnection 訪問磁貼并將它們存儲在本地.我的實現的 gist.
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.
這篇關于MapKit 中的 MapTypeStyle的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!