Tag: mapkit

我应该使用MKAnnotation,MKAnnotationView还是MKPinAnnotation?

我打电话给Web服务,并绘制一个MapView上的一些对象。 我不明白的是我应该使用MKAnnotationPoint还是MkAnnotationView? 我不确定。 当我使用MKAnnotation时,地图上显示的针脚,如果我点击他们,他们会显示标题和副标题。 如果我使用MKAnnotationView,引脚出现,但是当我点击它们时,什么都不会发生。 我也试图添加正确的button标注/雪佛龙看button,但还没有能够弄清楚。 这是我的代码的一个例子。 MKPointAnnotation mk = new MKPointAnnotation(); MKAnnotationView mkView = new MKAnnotationView(); mk.Coordinate = coord; mk.Title = tl.Name; mk.Subtitle = DateTime.Now.ToShortDateString(); mkView.Annotation = mk; mapView.AddAnnotationObject(mkView); 所以,如果我做了上述 – 针脚出现,但我不能点击其中任何一个。 如果我只是使用: mapView.AddAnotationObject(mk); //not using the MkAnnotationView 然后他们都出现,可点击。 我不知道如何添加rightcalloutbutton他们呢。 所以这是问题的第二部分。 谢谢。

自定义MKOverlayView线宽

我有一个自定义的MKOverlayView,它绘制了一个简单的线条。 在drawMapRect:我正在设置CGContextSetLineWidth(context, 30); 完全放大时看起来很好,但当缩小时,线条变得越来越薄。 MKOverlayView引用说它会自动缩放到地图的缩放级别。 无论我的缩放级别如何,我可以强制它绘制相同的宽度? 我注意到,MKPolylineView(和MKPolygonView)正确地做到了这一点…只要你缩放调整以保持相同的宽度,你可以看到线的宽度resize。 我怎么能在我的overlayView中做到这一点?

setNeedsDisplayInMapRect不会触发新的drawMapRect:call

我正在使用自定义的MKOverlay/MKOverlayView来完全覆盖Google自己的MKOverlay/MKOverlayView ,这些MKOverlay/MKOverlayView是asynchronous加载的。 当我收到一个canDrawMapRect:zoomScale:调用我的覆盖视图(并在这种情况下返回FALSE),然后调用setNeedsDisplayInMapRect:zoomScale:一旦该图块可用时,我遵循请求卸载的图块的模式。 这一切通常工作,似乎在模拟器中完美的工作。 但是,在设备上,我有时会在覆盖层上find一个“洞” – 一个缺失的瓷砖。 我可以看到该图块被请求,并且请求完成。 我可以看到我调用了setNeedsDisplayInMapRect:zoomScale: MKMapRect并且传递了MKZoomScale中提供的原始MKMapRect和canDrawMapRect:zoomScale: 但是我也可以看到覆盖层从来没有被要求重绘那个图块( canDrawMapRect:zoomScale:和drawMapRect:zoomScale:inContext:再次被调用该图块)。 我需要了解为什么会发生这种情况,以及如何纠正这种情况。 以下是我的MKOverlayView子类的相关代码: – (BOOL) canDrawMapRect: (MKMapRect) mapRect zoomScale: (MKZoomScale) zoomScale { NSUInteger zoomLevel = [self zoomLevelForZoomScale:zoomScale]; CGPoint mercatorPoint = [self mercatorTileOriginForMapRect:mapRect]; NSUInteger tilex = floor(mercatorPoint.x * [self worldTileWidthForZoomLevel:zoomLevel]); NSUInteger tiley = floor(mercatorPoint.y * [self worldTileWidthForZoomLevel:zoomLevel]); NSURL* tileUrl = [self tileURLForZoomLevel: zoomLevel tileX: tilex […]

如何使用mapKit框架自定义图标?

我正在使用MapKit框架来加载我的应用程序的谷歌地图,我放置在地图4“模拟”像这样的地方: – (void)viewDidLoad { [super viewDidLoad]; mapView.delegate = self; mapView.showsUserLocation = YES; MKUserLocation *userLocation = mapView.userLocation; MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance (userLocation.location.coordinate,500,500); [mapView setRegion:region animated:NO]; //Simulated annotations on the map CLLocationCoordinate2D poi1Coord , poi2Coord , poi3Coord , poi4Coord; //poi1 coordinates poi1Coord.latitude = 37.78754; poi1Coord.longitude = -122.40718; //poi2 coordinates poi2Coord.latitude = 37.78615; poi2Coord.longitude = -122.41040; //poi3 coordinates […]

根据用户当前在iOS7中的位置,RegionMonitoring监控的“region”的数量

我正在从事这样的项目,应用程序执行以下操作: 用户select一个半径(10米到1000米),然后按“Go”button进入下一个viewController 这里的应用程序抓住用户当前位置,并根据当前位置和选定的半径开始“区域监视” 如果用户跨越某个边界(10米到1000米),则会发出“ExitRegion”警报消息。 并根据用户新的当前位置再次启动“区域监控”。 而应用程序一直在做,无论是前景和背景模式。 我设法做到这一点,它正在完美的工作。 现在,我在这里监视一个地区,然后是另一个地区。 所以这个数字实际上是一个。 但我知道一个应用程序可以通过“区域监控”监控的区域的最大数量是15.现在我的问题是在这种情况下,我应该处理这个最大数量的区域问题吗? 如果是,那么如何? 还有一件事我想补充是,有一些解决scheme,它只适用于iOS 6和更早版本。 所以,请根据用户当前在iOS7中的位置,通过“RegionMonitoring”监控的“region”的处理数量来解决。 如果能够给出答案或任何build议来完成我的应用程序所需的要求,我将非常高兴。 先进的很多感谢。 祝你今天愉快。

从MKMapView中创build一个UIImage

我想从MKMapView创build一个UIImage 。 我的地图正确显示在视图中,但是生成的UIImage只是一个灰色的图像。 这是相关的片段。 UIGraphicsBeginImageContext(mapView.bounds.size); [mapView.layer renderInContext:UIGraphicsGetCurrentContext()]; mapImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 任何人都知道如何使用MapKit制作UIImage ?

在Xcode中打开本地谷歌地图

嗨,我有一个使用地图和位置的iPhone应用程序。 我希望用户能够按下一个button,该button将轮到该位置的转向。 我明白,我不允许在应用程序中这样做,但我想知道是否有人可以告诉我,如果有可能做一个链接到本地​​谷歌地图应用程序,将从用户当前位置进入方向的位置。 如果有可能你能告诉我怎么样? 任何帮助,将不胜感激。 谢谢

在iOS 7地图上显示路线:addOverlay没有效果

我想在我的mapView中显示一个点到点的路由,我用这个代码来创build路由: – (IBAction)backToYourCar { MKPlacemark *sourcePlacemark = [[MKPlacemark alloc] initWithCoordinate:self.annotationForCar.coordinate addressDictionary:nil]; NSLog(@"coordiante : locationIniziale %f", sourcePlacemark.coordinate.latitude); MKMapItem *carPosition = [[MKMapItem alloc] initWithPlacemark:sourcePlacemark]; MKMapItem *actualPosition = [MKMapItem mapItemForCurrentLocation]; NSLog(@"coordiante : source %f, ActualPosition %f", carPosition.placemark.coordinate.latitude ,actualPosition.placemark.coordinate.latitude); MKDirectionsRequest *request = [[MKDirectionsRequest alloc] init]; request.source = actualPosition; request.destination = carPosition; request.requestsAlternateRoutes = YES; MKDirections *directions = [[MKDirections alloc] […]

iOS MapKit用户位置注释的Z索引

我需要在所有其他注释之上绘制当前用户注释(蓝点)。 现在它正在我的其他注释下面被吸引,并被隐藏起来。 我想调整这个注解视图(蓝点)的z-index并将其带到最高处,有谁知道如何? 更新:所以我现在可以得到一个MKUserLocationView的句柄,但我该如何把它呢? – (void) mapView:(MKMapView *)aMapView didAddAnnotationViews:(NSArray *)views { for (MKAnnotationView *view in views) { if ([[view annotation] isKindOfClass:[MKUserLocation class]]) { // How do I bring this view to the front of all other annotations? // [???? bringSubviewToFront:????]; } } }

在MapKit中缩小和适合所有注释的最佳方式是什么?

我正在进行的快速背景。 UIMapView加载并显示单个注释(从不超过一个)。 在菜单栏上,有一个“我的我”button,点击时finduserLocation并显示为第二个注释。 然后我有MapView缩小以适应范围内的这些注释,但我无法find一个合适的方式这样做。 根据第一个注释与用户位置相关的位置,有时不会缩小到足够的位置。 例如,如果注释是用户的西北部,则缩小。 但是,如果注释位于用户的东南方,则只能将其缩小到足以让它们被切断,而且必须手动缩小一点。 这是我正在使用的代码,其他一些我已经find的变化。 CLLocation *whereIAm = mapView.userLocation.location; float lat = whereIAm.coordinate.latitude; float lon = whereIAm.coordinate.longitude; CLLocationCoordinate2D southWest = {[currentLatitude floatValue], [currentLongitude floatValue]}; CLLocationCoordinate2D northEast = southWest; southWest.latitude = MIN(southWest.latitude, lat); southWest.longitude = MIN(southWest.longitude, lon); northEast.latitude = MAX(northEast.latitude, lat); northEast.longitude = MAX(northEast.longitude, lon); CLLocation *locSouthWest = [[CLLocation alloc] initWithLatitude:southWest.latitude longitude:southWest.longitude]; CLLocation […]