mapkit

Replace icon pin by text label in annotation?

左心房为你撑大大i 提交于 2019-11-26 16:42:08
问题 Is it possible to replace the pin icon of an annotation by a dynamic text label? Maybe using css, or dynamically creating an image? For example a label is done with CSS on Google Maps API with JavaScript. 回答1: Yes, it's possible. In iOS MapKit, you'll need to implement the viewForAnnotation delegate method and return an MKAnnotationView with a UILabel added to it. For example: -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { if ([annotation

Detecting a point in a MKPolygon broke with iOS7 (CGPathContainsPoint)

感情迁移 提交于 2019-11-26 16:23:53
In a SO question I asked earlier this year, I got this chunk of code: MKPolygonView *polygonView = (MKPolygonView *)[self.mapView viewForOverlay:polygon]; MKMapPoint mapPoint = MKMapPointForCoordinate(tapCoord); CGPoint polygonViewPoint = [polygonView pointForMapPoint:mapPoint]; if (CGPathContainsPoint(polygonView.path, NULL, polygonViewPoint, FALSE)) { // do stuff } This works great up until iOS7. It now always returns false and will not detect a point with the path. I'm trying to find any documentation stating that the method change, but can't find any. Any ideas why it broke? Or a new

iPhone: Create MKAnnotation

谁说我不能喝 提交于 2019-11-26 16:09:07
问题 Can I create an MKAnnotation , or is it read only? I have coordinates, but I am not finding it easy to manually create an MKAnnotation with using setCoordinate . Ideas? 回答1: MKAnnotation is a protocol. So you need to write your own annotation object that implements this protocol. So your MyAnnotation header looks like: @interface MyAnnotation : NSObject<MKAnnotation> { CLLocationCoordinate2D coordinate; } @property (nonatomic, readonly) CLLocationCoordinate2D coordinate; // add an init method

How Do I Get The Correct Latitude and Longitude From An Uploaded iPhone Photo?

十年热恋 提交于 2019-11-26 16:05:17
问题 My problem actually seems rather silly... I am writing an iPhone application that uses MKMapKit. The app grabs the EXIF metadata from a provided geotagged photo. The problem is that the latitude and longitude coordinates that I retrieve, for example: Lat: 34.25733333333334 Lon: 118.5373333333333 returns a location in China. Is there a regional setting that I am missing or do I need to convert the lat/long coordinates before using them? Thank you all in advance for any help you can provide.

Why am I crashing after MKMapView is freed if I&#39;m no longer using it?

荒凉一梦 提交于 2019-11-26 15:38:25
问题 I have a MKMapView . Sometimes after my view controller is dismissed, I'll get a EXC_BAD_ACCESS . I turned on NSSZombies and it looks like the MKMapView 's delegate — my view controller! — is being called, despite both the MKMapView and UIViewController subclass being freed. I've checked, and my memory management is correct. What's going on? 回答1: This is because of the way MKMapView works. There's an operation pending, so MapKit is retaining the MKMapView and it hasn't actually been

Programmatically open Maps app in iOS 6

被刻印的时光 ゝ 提交于 2019-11-26 15:35:53
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? Here's the official Apple way: // Check for iOS 6 Class mapItemClass = [MKMapItem class]; if (mapItemClass && [mapItemClass respondsToSelector:

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

本秂侑毒 提交于 2019-11-26 15:20:23
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. First make your view controller implement the MKMapViewDelegate protocol and declare the properties you will need: @property (nonatomic, retain) MKMapView *mapView; //this is your map view @property (nonatomic, retain)

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

老子叫甜甜 提交于 2019-11-26 14:50:02
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": I don't know how exactly the bottom sheet of the new Maps app, responds to user interactions. But you can create a custom view that looks like the one

Custom MKPinAnnotation callout bubble similar to default callout bubble

允我心安 提交于 2019-11-26 12:25:59
问题 i want to create a custom callout bubble on MKMapView. But i want to create the call out bubble in the same manner of default bubble. So how to create a View look like annotaion in this image (source: objectgraph.com) I want a custom custom view which look like \"Parked Location\" annotaion in the following image. with custom width, height etc. P I am not able to add required details in Default bubble. Thats why am creating custom bubble. Plz help me..thanks.. 回答1: I have developed a custom

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

谁都会走 提交于 2019-11-26 12:22: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! Unfortunately, there's no such function provided in the API, so you'll have to write your own. This site gives several calculations involving latitude/longitude and sample JavaScript code. Specifically, the section titled