我有这个代码来设置用户位置的地图:
MKCoordinateSpan span;
span.latitudeDelta=0.2;
span.longitudeDelta=0.2;
CLLocationCoordinate2D location=mapView.userLocation.coordinate;
location = mapView.userLocation.location.coordinate;
MKCoordinateRegion region;
region.span=span;
region.center=location;
[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
Run Code Online (Sandbox Code Playgroud)
现在,当我这样做时,mapView.showsUserLocation=YES它显示我在正确位置的位置(在我的设备上,以及模拟器中的苹果公司),但是,上面的代码两次都把我放在非洲附近的某个海域!
有任何想法吗?
我遇到了一个崩溃,对我而言,好像这是Apple处理goToDefaultLocationMKMapView消息的方式.该消息依次调用[ALCityManager localeWithCode:],调用[NSLocale componentsFromLocaleIdentifier:]哪个调用调用CFLocaleCreateComponentsFromLocaleIdentifier哪个调用CFStringGetLength和崩溃.
有人可以帮我指出修复错误的方向,如果是我的代码导致这个,或者,帮助我找到一个解决方法,实际上,这是Apple的代码中的错误(不太可能?).
崩溃日志如下:
Incident Identifier: 84198BB6-45BD-493B-955F-75CCB5246DDD CrashReporter Key: 7dbf53bf1f1a3635d7c3c49e726dedc609ed9f3a Hardware Model: iPhone3,1 Process: MyApp [340] Path: /var/mobile/Applications/DCE9A5A1-8E24-4D4F-A1ED-9855C6CA1742/MyApp.app/MyApp Identifier: MyApp Version: ??? (???) Code Type: ARM (Native) Parent Process: launchd [1] Date/Time: 2011-03-25 10:36:06.382 -0700 OS Version: iPhone OS 4.3 (8F190) Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000 Crashed Thread: 0 Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 CoreFoundation 0x00009a66 CFStringGetLength …
我有一个MKMapView,我正在添加一个叠加(MKOverlay).
我想叠加层使下面的地图视图显示为黑白(即单色).有没有办法做到这一点?
(我想我可以使叠加半透明的黑色/灰色,但这不是我想要的确切效果.)
系统详细信息:在Xcode 4.2中开发iOS 5应用程序.
我试图找出MKMapRect的大小(即iPhone的320x568分).
是否有类似于将坐标转换为点的东西?即
[self.mapView convertCoordinate:coordinate1 toPointToView:self.view];
Run Code Online (Sandbox Code Playgroud) 我有问题要在MKMapKit中加载512x512px图块.服务器提供512x512 .jpeg磁贴.
我在MKMapView中找不到自定义视网膜图块的任何解决方案或示例实现.
我所做的:
当我将它们加载到MKMapView中时
overlay = [[MKTileOverlay alloc] initWithURLTemplate:template];
overlay.tileSize = CGSizeMake(512.0f, 512.0f);
[_mapView insertOverlay:overlay atIndex:MAP_OVERLAY_INDEX_TILE level:MKOverlayLevelAboveLabels];
Run Code Online (Sandbox Code Playgroud)
...瓷砖缩放正确但只加载了一半(不仅在视觉上 - 我嗅探了请求并且缺少了瓷砖)
同
overlay = [[MKTileOverlay alloc] initWithURLTemplate:template];
overlay.tileSize = CGSizeMake(256.0f, 256.0f);
[_mapView insertOverlay:overlay atIndex:MAP_OVERLAY_INDEX_TILE level:MKOverlayLevelAboveLabels];
Run Code Online (Sandbox Code Playgroud)
...显示所有图块但缩放不正确
这是我的绘图方法:
(MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id <MKOverlay>)overlay
{
MKOverlayRenderer *overlayRenderer = nil;
if([overlay isKindOfClass:MKTileOverlay.class])
{
overlayRenderer = [[MKTileOverlayRenderer alloc] initWithTileOverlay:overlay];
}
return overlayRenderer;
}
Run Code Online (Sandbox Code Playgroud)
... overlayRenderer.contentScaleFactor总是1 ...无论是什么tileSize(iOS模拟器7.1视网膜)
有什么建议?
最好的问候,史蒂夫
是否可以使用Apple Maps API在中间使用航路点从A到B获取折线?我尝试这样请求:
A -> A1 A1 -> A2 A2 -> A3 ... AN -> B
但显然苹果服务器在我经常这样做的时候停止响应,所以我正在寻找一种方法如何很好地获得它而不会像这样重载Apple服务器:
A -> A1 -> A2 -> A3 -> .... -> B
谁知道如何实现这个目标?
是否可以在不提供naturalLanguageQuery的情况下使用MKLocalSearchRequest显示附近的地方?
我知道典型的路线是使用foursquare或google.我用过这两个.
构建和启动我的应用程序后,我收到以下错误.我无法追查导致它的原因,但一切都运行良好.我正在使用MapKit而不确定是否会导致它.
Connection error while checking Apple Internalness. Error: Error
Domain=NSCocoaErrorDomain Code=4099 "Couldn’t communicate with
a helper application." (The connection to service named
com.apple.CrashReporterSupportHelper was invalidated.) UserInfo=0x608000279540
{NSDebugDescription=The connection to service named
com.apple.CrashReporterSupportHelper was invalidated.}
Run Code Online (Sandbox Code Playgroud) 我收到了这个错误
"Nil与返回类型'MKOverlayRenderer'不兼容".
这是我的代码:
func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer {
if overlay is MKCircle {
let circleRenderer = MKCircleRenderer(overlay: overlay)
circleRenderer.lineWidth = 1.0
circleRenderer.strokeColor = UIColor.purpleColor()
circleRenderer.fillColor = UIColor.purpleColor().colorWithAlphaComponent(0.4)
return circleRenderer
}
return nil
}
Run Code Online (Sandbox Code Playgroud)
它为什么会发生?
我正在尝试学习MapKit,现在我正在尝试将图像(不是多边形,圆形,矩形等)添加 为地图视图的叠加层.我似乎无法找到任何示例代码来帮助解释如何执行此操作.
到目前为止,我在ViewController.swift中的代码是:
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
@IBOutlet var mapView: MKMapView!
var locationManager: CLLocationManager!
var mapOverlay: MKOverlay!
override func viewDidLoad() {
super.viewDidLoad()
//Setup our Location Manager
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startUpdatingLocation()
//Setup our Map View
mapView.delegate = self
mapView.mapType = MKMapType.Satellite
mapView.showsUserLocation = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Run Code Online (Sandbox Code Playgroud)
我知道我需要使用:
func mapView(mapView: MKMapView, rendererForOverlay …Run Code Online (Sandbox Code Playgroud)