mapkit

MapKit : Add custom callout

半世苍凉 提交于 2019-12-12 23:04:30
问题 I want to add custom annotationView callout which contains 1. Title 2. subtitles 3. a button The button can display on the right ( rightCalloutAccessoryView ) or left leftCalloutAccessoryView sides of the callout. I want to add the button in the middle of the callout and under title->subtitle. How can I do? 回答1: There is no API for this. You could try not using the standard callout (canShowCallout = NO), catch the taps and drags on the AnnotationView manually and show your own UI by adding

How to change marker icon?

回眸只為那壹抹淺笑 提交于 2019-12-12 21:52:47
问题 I was wonderring if there is a way to change those red pins that are used as markers. And if there is a way, how to do it? 回答1: you can use 3 types of color pins in mapView are bellow.. MKPinAnnotationColorGreen; MKPinAnnotationColorPurple MKPinAnnotationColorRed and if you want to add customview or image then you can add with programatically also you can change pin in delegate method of MKMapView like bellow.. - (MKAnnotationView *)mapView:(MKMapView *)_mapView viewForAnnotation:(id

Map view dropping multiple pins

风流意气都作罢 提交于 2019-12-12 20:57:03
问题 I want to show user location on map and drop a pin but my app drops two pins separated at some distance.I want to know how can i remove the old pin when new pin is dropped so that there should be one pin on map My code is: -(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation: (id <MKAnnotation>)annotation { MKPinAnnotationView *pinView = nil; if(annotation != mapView.userLocation) { static NSString *defaultPinID = @"com.invasivecode.pin"; pinView = (MKPinAnnotationView *)[mapView

How to route between two addresses using the new iOS 6.0 maps?

北城余情 提交于 2019-12-12 17:19:45
问题 I'm using the iOS 6.0 SDK and I would like to route between two different addresses (not latitude and longitude) with Apple's new iOS 6.0 maps. I would like to show the indications too. How can I do this? 回答1: I looked into do doing this last week and did not figure out a way to do it. It appears that you can give a destination, and you can sort of give it more than just coordinates, but it always assumes your starting position is the current location. That is limiting when you may be

Calculate ETA in Swift

旧时模样 提交于 2019-12-12 14:15:11
问题 I'm attempting to calculate the estimated travel time (walking) between two locations in swift, the user to an annotation. Here is my current code, it does not throw any errors that crash the program but only returns "Error while requesting ETA" import UIKit import MapKit class LocationObjects: NSObject, MKAnnotation { /*let userView = CLLocation(latitude: mapView.centerCoordinate.latitude, longitude: mapView.centerCoordinate.longitude) let annotationPoint = CLLocation(latitude: annotation

Change color of pulsing blue ring around user's location

微笑、不失礼 提交于 2019-12-12 11:59:37
问题 I've scoured the web and haven't found a way to customize the color of the blue pulsing ring around the user's location on a map. Does anyone know a way to customize the color of the pulsing ring? 回答1: This open source project might be useful: https://github.com/samvermette/SVPulsingAnnotationView 回答2: The blue color for the user location is based on the tint color of your map view, changing this will set the new color for the user location circle. //Objective-C mapView.tintColor = [UIColor

Get right zoom area for CLPlacemark

拥有回忆 提交于 2019-12-12 11:37:55
问题 I'm using MKLocalSearch to search for certain places like cities or streets in cities to shown them on an MKMapView I show the placemark like this let loc = placemark.location! //CLLocation of CLPlacemark var mapRegion = MKCoordinateRegion() mapRegion.center.longitude = loc.coordinate.longitude mapRegion.center.latitude = loc.coordinate.latitude mapRegion.span.latitudeDelta = 0.03 // I choose 0.03 by trying mapRegion.span.longitudeDelta = 0.03 mapView.setRegion(mapRegion, animated: true) This

Custom MKOverlayView/unmodified MKPolygonView is clipped at certain zoom levels

偶尔善良 提交于 2019-12-12 10:58:16
问题 I'm having an issue with both a custom MKOverlayView and standard MKPolygonView being clipped at certain zoom levels when there are multiple overlays added to a map. The overlay of Algeria at two double tap zoom level. The overlay of Algeria at three double tap zoom level. Note the clipping. A few observations: This occurs regardless of whether or not I use a custom MKOverlayView or return an MKPolygonView with the same polygons. If I only draw one overlay, this problem does not occur. This

how to get the current location position in map on iphone

不想你离开。 提交于 2019-12-12 10:24:32
问题 i am creating an application in which i want to get the current location of the user where he is and display it on the map and when the user reaches the destination location from current location the destination location should also be pointed in the map along the direction of travel. In my xib i have added a button & on action(showDirectionsToHere) of button i have called map I have added the following code in my appdelegate but it gives me an error: - (void)locationManager:

Why after upgrading to Xcode 4.2 does MKAnnotation display a warning

泄露秘密 提交于 2019-12-12 10:05:45
问题 In Xcode 4.1 there was no problem, but upgrading to Xcode 4.2 I get the following warning: Property 'title' 'copy' attribute does not match the property inherited from 'MKAnnotation' Property 'subtitle' 'copy' attribute does not match the property inherited from 'MKAnnotation' My code: @interface MyAnnotation : NSObject <MKAnnotation> { CLLocationCoordinate2D coordinate; NSString *subtitle; NSString *title; } @property (nonatomic, readonly) CLLocationCoordinate2D coordinate; @property