mapkit

Positioning MKMapView to show multiple annotations at once

主宰稳场 提交于 2019-11-26 04:29:54
问题 I\'ve got several annotations I want to add to my MKMapView (it could 0-n items, where n is generally around 5). I can add the annotations fine, but I want to resize the map to fit all annotations onscreen at once, and I\'m not sure how to do this. I\'ve been looking at -regionThatFits: but I\'m not quite sure what to do with it. I\'ll post some code to show what I\'ve got so far. I think this should be a generally straightforward task but I\'m feeling a bit overwhelmed with MapKit so far. -

Programmatically open Maps app in iOS 6

孤街醉人 提交于 2019-11-26 04:29:20
问题 Previous to iOS 6, opening a URL like this would open the (Google) Maps app: NSURL *url = [NSURL URLWithString:@\"http://maps.google.com/?q=New+York\"]; [[UIApplication sharedApplication] openURL:url]; Now with the new Apple Maps implementation, this just opens Mobile Safari to Google Maps. How can I accomplish the same behavior with iOS 6? How do I programmatically open the Maps app and have it point to a specific location/address/search/whatever? 回答1: Here's the official Apple way: // Check

iPhone: How to draw line between two points on MapKit?

假如想象 提交于 2019-11-26 04:21:34
问题 I have Latitude and Longitude of two points and Want to Draw line between these two points with Pin on MapKit. I have googled but Could not find some suitable solution because the one I found was drawing overlay with array of Data points but I do not have any array of points between these two points. Just two points and want to draw line between these two points. Please help. 回答1: First make your view controller implement the MKMapViewDelegate protocol and declare the properties you will need

How to customize the callout bubble for MKAnnotationView?

泪湿孤枕 提交于 2019-11-26 03:47:01
问题 I\'m currently working with the mapkit and am stuck. I have a custom annotation view I am using, and I want to use the image property to display the point on the map with my own icon. I have this working fine. But what I would also like to do is to override the default callout view (the bubble that shows up with the title/subtitle when the annotation icon is touched). I want to be able to control the callout itself: the mapkit only provides access to the left and right ancillary callout views

How can I mimic the bottom sheet from the Maps app?

别来无恙 提交于 2019-11-26 03:46:08
问题 Can anyone tell me how I can mimic the bottom sheet in the new Maps app in iOS 10? In Android, you can use a BottomSheet which mimics this behaviour, but I could not find anything like that for iOS. Is that a simple scroll view with a content inset, so that the search bar is at the bottom? I am fairly new to iOS programming so if someone could help me creating this layout, that would be highly appreciated. This is what I mean by \"bottom sheet\": 回答1: I don't know how exactly the bottom sheet

Calculate new coordinate x meters and y degree away from one coordinate

不问归期 提交于 2019-11-26 03:35:58
问题 I must be missing somthing out in the docs, I thought this should be easy... If I have one coordinate and want to get a new coordinate x meters away, in some direction. How do I do this? I am looking for something like -(CLLocationCoordinate2D) translateCoordinate:(CLLocationCoordinate2D)coordinate translateMeters:(int)meters translateDegrees:(double)degrees; Thanks! 回答1: Unfortunately, there's no such function provided in the API, so you'll have to write your own. This site gives several

Drawing a route in MapKit in iOS

为君一笑 提交于 2019-11-26 02:42:02
问题 I want to draw a route between two locations on the map. Something like a tour guide. When the tourist clicks another location, I want to be able to draw a route; as well as, inform about the distance from the current location. I am aware of sites on the Internet which tell how to draw polylines on map. But, most of the examples had a preloaded .csv file with various coordinates. Is there an alternative way to get the coordinates from Google or any other provider, as the location is selected

UIImage(contentsOfFile:) returning nil despite file existing in caches directory [duplicate]

六眼飞鱼酱① 提交于 2019-11-26 00:38:33
问题 This question already has answers here : NSFileManager.defaultManager().fileExistsAtPath returns false instead of true (2 answers) Closed last year . I\'m trying to save a snapshot of a map with an overlay in the caches directory and retrieve it when it exists. However, despite the file being created, UIImage(contentsOfFile:) returns nil when I try to retrieve it. I\'ve printed the file paths for both write and read and they are the same and have verified the file exists by downloading the

How to pass prepareForSegue: an object

百般思念 提交于 2019-11-25 21:47:01
问题 I have many annotations in a mapview (with rightCalloutAccessory buttons). The button will perform a segue from this mapview to a tableview . I want to pass the tableview a different object (that holds data) depending on which callout button was clicked. For example: (totally made up) annotation1 (Austin) -> pass data obj 1 (relevant to Austin) annotation2 (Dallas) -> pass data obj 2 (relevant to Dallas) annotation3 (Houston) -> pass data obj 3 and so on... (you get the idea) I am able to