Tag: mapkit

如何在UIView中绘制与MKPolyline相同的UIBezierPath

目前我正在跟踪我的位置在一个MKMapView。 我的目标是绘制一个与从追踪位置创build的MKPolyline相同的贝塞尔path。 我所尝试的是:将所有位置坐标存储在CLLocation数组中。 迭代该数组,并将经纬度坐标存储在CLLocationCoordinate2D数组中。 然后确保多段线在屏幕的视图中,然后转换CGPoints中的所有位置坐标。 当前尝试: @IBOutlet weak var bezierPathView: UIView! var locations = [CLLocation]() // values from didUpdateLocation(_:) func createBezierPath() { bezierPathView.isHidden = false var coordinates = [CLLocationCoordinate2D]() for location in locations { coordinates.append(location.coordinate) } let polyline = MKPolyline(coordinates: coordinates, count: coordinates.count) fitPolylineInView(polyline: polyline) let mapPoints = polyline.points() var points = [CGPoint]() for point […]

iOS MapKit通过道路在地图上连接多个点

我正在使用此代码连接折线上的针脚(地图上的点): CLLocationCoordinate2D coordinates[allLocations.count]; int i = 0; for (locHolder *location in allLocations) { coordinates[i] = CLLocationCoordinate2DMake([location.lat floatValue], [location floatValue]); i++; } MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coordinates count:[allLocations count]]; self->polyline = polyline; [self.mapView addOverlay:self->polyline level:MKOverlayLevelAboveRoads]; 但是这个代码将它们连接在空中(忽略道路),是否有可能将多个CLLocationCoordinate2D位置连接到沿着道路的多段线? **还有一个小问题,[allLocations count]和allLocations.count之间的性能是否有差异? 谢谢。

在MapView注释中更长的字幕(swift)

我有一个显示标题和字幕的注解的地图视图。 字幕有时比注释的宽度长,所以我想知道如果我可以让他们多线? 它是这样编码的: func annotate(newCoordinate, title: String, subtitle: String) { let annotation = MKPointAnnotation() annotation.coordinate = newCoordinate annotation.title = title annotation.subtitle = subtitle self.map.addAnnotation(annotation) } 然后我有几个选项设置 func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {…} 这里没有关系。 是否可以做一个自定义的注释视图? 我已经尝试了几件事,但没有任何工作。 我能得到的最接近的是添加一个button来分别显示较长的字幕,但我宁愿在注释中。 可能吗?

在放大时使用MKMapView在setUserTrackingMode上崩溃

我有MKUserTrackingModeFollowWithHeading MKMapView。 但是有些东西把userTrackingMode改为MKUserTrackingModeFollow或None,所以我实现了, – (void)mapView:(MKMapView *)mapView didChangeUserTrackingMode:(MKUserTrackingMode)mode animated:(BOOL)animated { if ([CLLocationManager locationServicesEnabled]) { if ([CLLocationManager headingAvailable]) { [self.myMapView setUserTrackingMode:MKUserTrackingModeFollowWithHeading animated:NO]; }else{ [self.myMapView setUserTrackingMode:MKUserTrackingModeFollow animated:NO]; } }else{ [self.myMapView setUserTrackingMode:MKUserTrackingModeNone animated:NO]; } } 一切都很好,但每次我放大地图到最详细的水平,应用程序导致EXC_BAD_ACCESS行setUserTrackingMode:MKUserTrackingModeFollowWithHeading上面显示。 我应该怎么做才能避免崩溃? 如果可能,我不想使用MKUserTrackingBarButtonItem。 下面是mapViewController的其他部分。 – (void)dealloc { self.myMapView.delegate = nil; } – (void)viewWillDisappear:(BOOL)animated { if ([CLLocationManager locationServicesEnabled]) { self.myMapView.showsUserLocation = NO; [_locManager stopUpdatingLocation]; if […]

打开要求select应用程序打开地图的警报

我有一个集成了地图工具包的视图控制器。 我需要在打开地图之前拍摄一个警报,要求从所有类似的地图应用程序中select打开。 例如,如果谷歌地图应用程序安装在我的iPhone中,应该有一个选项,以及默认的地图包视图。 是否有可能实现这一function,扫描每个类似的应用程序从iPhone和返回结果作为选项打开地图。

MKPolyline / MKPolylineRenderer改变颜色而不删除它

我与地图应用程序工作,我想问如何更改折线颜色不删除,并再次添加,我发现这个话题https://stackoverflow.com/questions/24226290/mkpolylinerenderer-change-color-without-removing-叠加在stackoverflow但这不涉及我的问题,我没有触及行,所以不需要做-[MKMapViewDelegate mapView:didSelectAnnotationView:] 那么有可能做到这一点? 编辑:我想要做的是平滑地改变折线颜色(通过阴影颜色 – 声音像animation)如果你有任何想法如何animation这个折线,请也告诉我。 谢谢

黑色和白色覆盖MKMapView

我有一个MKMapView,并添加覆盖(MKOverlay)。 我希望覆盖层使地图视图下方显示黑白(即单色)。 有没有办法做到这一点? (我想我可以使覆盖半透明的黑色/灰色,但这不是我想要的确切效果。) 系统详细信息:在Xcode 4.2中开发iOS 5应用程序。

如何添加触摸手势映射,但忽略引脚和注释触摸?

我有一个使用MKCircle s来显示某些用户操作的半径信息的mapview。 我想要做的就是允许用户在触摸地图时closuresMKCircle 。 不过,我希望MKCircle不要解雇,如果用户触摸任何其他针或MKCircle本身。 有任何想法吗? 这里是我当前的代码,当地图的任何部分被触摸时,它将closuresMKCircle : UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(deactivateAllRadars)]; [tap setCancelsTouchesInView:NO]; [_mapView addGestureRecognizer:tap];

Xcode错误:sockets无法连接到重复的内容

经过一些search和编辑,我似乎无法find一个解决scheme来解决这个错误。 我试图将我的位置search结果与表格链接,以列表forms显示search结果。 我有我的地图与详细信息button与一个名为“FirstViewController”UIViewController链接。 我的结果表与一个名为“ResultsTableViewController”的UITableViewController链接。 我的原型单元格与名为“ResultsTableCell”的UITableViewCell链接,这也是我的网点所在的位置。 这里是两个单独的错误: 非法configuration:从ResultsTableViewController到UILabel的nameLabelsockets无效。 sockets不能连接到重复的内容。 非法configuration:从ResultsTableViewController到UILabel的phoneLabelsockets无效。 sockets不能连接到重复的内容。 我已经读过其他人的post相同的问题,试图相应地解决他们,我仍然得到同样的错误。 这是填充单元格的代码,位于我的ResultsTableViewController中。 let cell = tableView.dequeueReusableCellWithIdentifier("resultCell", forIndexPath: indexPath) as! ResultsTableCell // Configure the cell… let row = indexPath.row let item = mapItems[row] cell.nameLabel.text = item.name cell.phoneLabel.text = item.phoneNumber return cell } 我的ResultsTableCell类中的代码: import UIKit class ResultsTableCell: UITableViewCell { @IBOutlet weak var nameLabel: UILabel! @IBOutlet weak […]

美国所有州的iOS覆盖(MKPolygon)数据?

在“ iOS开发者库位置感知编程指南”的“ 在地图上显示覆盖图”部分,有一个示例“显示覆盖科罗拉多州的填充和描边覆盖图”。 // Define an overlay that covers Colorado. CLLocationCoordinate2D points[4]; points[0] = CLLocationCoordinate2DMake(41.000512, -109.050116); points[1] = CLLocationCoordinate2DMake(41.002371, -102.052066); points[2] = CLLocationCoordinate2DMake(36.993076, -102.041981); points[3] = CLLocationCoordinate2DMake(36.99892, -109.045267); MKPolygon* poly = [MKPolygon polygonWithCoordinates:points count:4]; poly.title = @"Colorado"; [map addOverlay:poly]; 问题是否有美国所有50个州的坐标数据来源,使用相同的纬度/经度数据,随时可用?