mkoverlay

How do I create an image overlay and add to MKMapView in Swift 2?

杀马特。学长 韩版系。学妹 提交于 2020-01-12 08:09:31
问题 I am trying to learn MapKit and am now trying to add an image (not a polygon, circle, rectangle, etc.) as an overlay to the map view. I can't seem to find any sample code to help explain how to do this. So far my code in ViewController.swift is: import UIKit import MapKit import CoreLocation class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate { @IBOutlet var mapView: MKMapView! var locationManager: CLLocationManager! var mapOverlay: MKOverlay! override func

Moving MKCircle on MKMapview and dragging MKMapview

萝らか妹 提交于 2020-01-04 14:28:12
问题 I have a MKCircle on MKMapView. It is user-draggable, but if the user drags the area outside the circle, the map should be moving instead. - (IBAction)createPanGestureRecognizer:(id)sender { _mapView.scrollEnabled=NO; _panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(respondToPanGesture:)]; [_mapView addGestureRecognizer:_panRecognizer]; } -(void)respondToPanGesture:(UIPanGestureRecognizer*)sender { static CGPoint originalPoint; if (sender.state ==

How to draw UIBezierPath overlay on MKMapView?

为君一笑 提交于 2020-01-02 21:54:31
问题 I try to subclass from MKOverlayPathRenderer and implement -createPath - (void)createPath { MKPolyline *line = (id)self.overlay; MKMapPoint *points = line.points; NSUInteger pointCount = line.pointCount; CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, points[0].x, points[0].y); for (int i = 1; i < pointCount; i++) { CGPathAddLineToPoint(path, NULL, points[i].x, points[i].y); } [self setPath:path]; } I create overlay here: CLLocationCoordinate2D coordinates[events

Custom map path line

偶尔善良 提交于 2020-01-01 15:35:03
问题 I'm having trouble with drawing a line on the map with a stroke. (inside color and outside color) I beleive i'm on the right path and have subclassed mkOverlayView to override the drawing (needs to fill with the road size) so inside drawMapRect... CGFloat lineWidth = MKRoadWidthAtZoomScale(zoomScale); MKMapRect clipRect = MKMapRectInset(mapRect, -lineWidth, -lineWidth); ... CGContextAddPath(context, path); CGContextSetStrokeColorWithColor(context, line.color.CGColor); CGContextSetLineJoin

How to fill outside overlay circle in iOS 7 on map

我的未来我决定 提交于 2019-12-30 05:17:05
问题 I need the same filled space around circle on the map as in Reminders app in iOS7. I think need to use the method applyFillPropertiesToContext:atZoomScale or fillPath:inContext: . 回答1: I solved my problem: - (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context { // Fill full map rect with some color. CGRect rect = [self rectForMapRect:mapRect]; CGContextSaveGState(context); CGContextAddRect(context, rect); CGContextSetFillColorWithColor(context

Draw a circle of 1000m radius around users location in MKMapView

谁说胖子不能爱 提交于 2019-12-28 01:43:46
问题 (Using iOS 5 and Xcode 4.2) I have an MKMapView and want to draw a circle of 1000m radius around the user location. On the surface it would seem that implementing the mapView:viewForAnnotation: map view delegate method, and adding a custom MKAnnotationView for the users location, would be a perfect solution. It would look something like this: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { // If it's the user location, return my custom

Is CGPoint in MKPolygonView?

本秂侑毒 提交于 2019-12-25 09:40:36
问题 I'm trying to figure out a way to detect which MKOverlayView (actually MKPolygonView ) was tapped and then change its color. I got it running with this code: - (void)mapTapped:(UITapGestureRecognizer *)recognizer { MKMapView *mapView = (MKMapView *)recognizer.view; MKPolygonView *tappedOverlay = nil; for (id<MKOverlay> overlay in mapView.overlays) { MKPolygonView *view = (MKPolygonView *)[mapView viewForOverlay:overlay]; if (view){ // Get view frame rect in the mapView's coordinate system

How to capture Tap gesture on MKMapView

筅森魡賤 提交于 2019-12-25 02:15:54
问题 I am trying to capture tap event on my MKMapView , this way I can drop a MKPinAnnotation on the point where user tapped. Basically I have a map overlayed with MKOverlayViews (an overlay showing a building) and I would like to give user more information about that Overlay when they tap on it by dropping a MKPinAnnotaion and showing more information in the callout. Thank you. 回答1: You can use a UIGestureRecognizer to detect touches on the map view. Instead of a single tap, however, I would

Swift 2 MKMapViewDelegate rendererForOverlay compiler warning

余生颓废 提交于 2019-12-23 09:32:48
问题 I am trying to draw a polyline on a map in Swift 2. It all works well, but I get a compiler warning for this code: func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! { if overlay is MKPolyline { let polylineRenderer = MKPolylineRenderer(overlay: overlay) polylineRenderer.strokeColor = UIColor.redColor() polylineRenderer.lineWidth = 5 return polylineRenderer } return nil } This will give me a warning says that ' Result and parameters in mapView

Draw polyline between given points on the map

为君一笑 提交于 2019-12-22 18:22:05
问题 I am implementing an iOS application, and I want to draw a polyline between several given coordinates on the map. I wrote the code and got the polylines being drawn from my point reaching an infinite point. In other words the beginning point of the line starts from the my given lat and long point, but the end of the line is infinite and not the other point. This is my code... I filled the coordinates in a NSMutableArray called routeLatitudes . The array cells are being filled one for latitude