mapkit

iOS MapKit custom pins

旧巷老猫 提交于 2019-11-27 10:51:41
问题 How do I show images instead of pins in the map. So far I can only add pins on tap. A sample code of the .m would extremely help since i'm still new to iOS programming. 回答1: #pragma mark - #pragma mark MKMapView delegate - (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id <MKAnnotation>)annotation { if ([annotation isKindOfClass:[MKUserLocation class]]) return nil; static NSString* AnnotationIdentifier = @"AnnotationIdentifier"; MKAnnotationView *annotationView = [mapView

How to move a MKAnnotation without adding/removing it from the map?

断了今生、忘了曾经 提交于 2019-11-27 10:46:50
问题 Is it possible to move the coordinate of a MKAnnotation without adding and removing the annotation from the map? 回答1: I found a pretty simple method. I wanted to update my player's position smoothly without removing and then re-adding the player annotation. This works well for pre-iOS4 apps, and what it does is both move the pin and center the map on the pin's new location: [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationCurve

detect if a point is inside a MKPolygon overlay

自作多情 提交于 2019-11-27 10:35:00
问题 I want to be able to tell if tap is within a MKPolygon. I have a MKPolygon: CLLocationCoordinate2D points[4]; points[0] = CLLocationCoordinate2DMake(41.000512, -109.050116); points[1] = CLLocationCoordinate2DMake(41.002371, -102.052066); points[2] = CLLocationCoordinate2DMake(36.993076, -102.041981); points[3] = CLLocationCoordinate2DMake(36.99892, -109.045267); MKPolygon* poly = [MKPolygon polygonWithCoordinates:points count:4]; [self.mapView addOverlay:poly]; //create UIGestureRecognizer to

Setting the zoom level for a MKMapView

蓝咒 提交于 2019-11-27 10:25:05
I have a map which shows correctly, the only thing I want to do now is set the zoom level when it loads. Is there a way to do this? Thanks Carnal I found myself a solution, which is very simple and does the trick. Use MKCoordinateRegionMakeWithDistance in order to set the distance in meters vertically and horizontally to get the desired zoom. And then of course when you update your location you'll get the right coordinates, or you can specify it directly in the CLLocationCoordinate2D at startup, if that's what you need to do: CLLocationCoordinate2D noLocation; MKCoordinateRegion viewRegion =

I want to get the Location name from the Coordinate value in MapKit for iPhone

南笙酒味 提交于 2019-11-27 10:21:31
问题 I want to get the location name from the coordinate value. Here is code, - (void)viewWillAppear:(BOOL)animated { CLLocationCoordinate2D zoomLocation; zoomLocation.latitude = 39.281516; zoomLocation.longitude= -76.580806; MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE); MKCoordinateRegion adjustedRegion = [_mapView regionThatFits:viewRegion]; [_mapView setRegion:adjustedRegion animated:YES]; } So, From that Latitude and

iOS Swift MapKit Custom Annotation [closed]

喜欢而已 提交于 2019-11-27 09:38:14
问题 I am having some trouble getting a custom annotation to load inside of my map view when I try to place a pin. import UIKit import MapKit import CoreLocation class MapViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate{ @IBAction func ReportBtn(sender: AnyObject) { //MARK: Report Date And Time Details let ReportTime = NSDate() let TimeStamp = NSDateFormatter() TimeStamp.timeStyle = NSDateFormatterStyle.ShortStyle TimeStamp.dateStyle = NSDateFormatterStyle.ShortStyle

How do i open Google Maps for directions using coordinates on the iphone

安稳与你 提交于 2019-11-27 09:37:33
问题 I am using UIMapView to display locations on the iPhone. I want to do a directions from current location to the location of interest, I don't think its possible using MapKit (but if it is please inform) So I will open either the Google Maps application or safari to display it. Can i do this by specifying co-ordinates from (current location) to co-ordinates (the location of interest) I have these longitudes and latitudes. Or do i have to use street addresses? If I do have to use street

MKPolygon area calculation

我与影子孤独终老i 提交于 2019-11-27 08:57:43
I'm trying to make an area calculation category for MKPolygon. I found some JS code https://github.com/mapbox/geojson-area/blob/master/index.js#L1 with a link to the algorithm: http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409 . It says: Here is my code, which gave a wrong result (thousands times more than actual): #define kEarthRadius 6378137 @implementation MKPolygon (AreaCalculation) - (double) area { double area = 0; NSArray *coords = [self coordinates]; if (coords.count > 2) { CLLocationCoordinate2D p1, p2; for (int i = 0; i < coords.count - 1; i++) { p1 = [coords[i] MKCoordinateValue]

How to reorder MKMapView annotations array

拈花ヽ惹草 提交于 2019-11-27 08:35:08
问题 I'd like to reorder the array of annotations shown on a map in order to create a next/prev button for quickly cycling through all annotations (sorted by date) using a simple iterator. As far as I see the annotations array used as a store [worldmap annotations] is not mutable and therefore I cannot reorder it. I tried the following to create a temporary copy of the annotations array, sort it by date and re-attach it. ( worldmap is my MKMapView object) //COPY NSMutableArray *annotationSort = [

change UIImage from MKAnnotation in the MKMapView

删除回忆录丶 提交于 2019-11-27 08:33:40
问题 I have a mapView with only on MKAnnotation, that has a costume image. When the user changes the mapType, I need to change the image of that annotation. The way I did that was to remove the annotation from the map, and insert another with the correct image, bu i don't think is the best way. It takes about 1 ou 2 seconds to show the new image. How can I do it without remove the annotation and drop another? Thanks, RL 回答1: You can use the viewForAnnotation: instance method of the map view (not