mkmapview

Draw simple Text in a MKPolygonView

試著忘記壹切 提交于 2019-12-11 01:46:03
问题 Hello I try to draw text in a MKPolygonView. I made a subclass of MKPolygonView and added it to my MKMapView. The Polygon shows up correctly, but I can't see the Text. Can anyone help me? -(void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context{ [super drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context]; CGRect overallCGRect = [self rectForMapRect:self.overlay.boundingMapRect]; UIFont* font = [UIFont

Strange behavior of MKMapView visibleMapRect property

瘦欲@ 提交于 2019-12-11 01:37:16
问题 I tried to set visibleMapRect property of MKMapView object but result map rect is not the exact what I expected. This is my code: NSLog(@"current size %f %f", mapView.visibleMapRect.size.width, mapView.visibleMapRect.size.height); NSLog(@"target size %f %f", newBounds.size.width, newBounds.size.height); mapView.visibleMapRect = newBounds; NSLog(@"new size %f %f", mapView.visibleMapRect.size.width, mapView.visibleMapRect.size.height); And this is the result: 2013-01-15 19:21:25.440 MyApp[4216

MKMapPointForCoordinate returning invalid coordinates

烂漫一生 提交于 2019-12-11 00:09:34
问题 I am working with MKMapView's, annotations, overlays, etc, but I'm having a pain in the butt issue with MKMapPointForCoordinate() returning an invalid coordinate. Code: MKMapPoint* pointArr; for (Category* route in validRoutes){ NSString* routeID = [route routeid]; NSArray* pointData = [routes objectForKey:routeID]; pointArr = malloc(sizeof(MKMapPoint) * [pointData count]); int i = 0; for (NSDictionary* routeData in pointData) { NSString* latitude = [routeData objectForKey:@"latitude"];

MkMapview Annotation title is not showing

橙三吉。 提交于 2019-12-10 23:28:56
问题 I am using mkmapview in my app. I am showing annotation in my app. But annotation title is not showing in my map view. Here is my code: func loadMaps(){ let shopsArray = self.locationlatlong as NSArray print(shopsArray) for shop in shopsArray { let annotation = MKPointAnnotation() let mylatitude : String = shop["letitude"] as! String let string = NSString(string: mylatitude) let mylatitudeFinal = string.doubleValue print(mylatitude) print(mylatitudeFinal) let mylongitude : String = shop[

How to set the PlaceMark position in MKMapView?

佐手、 提交于 2019-12-10 23:10:47
问题 MKMapView show the pin on the center of the mapView, I want to position the pin location above the center. How do I do that? Here is my code - (void) location { MKCoordinateRegion region; MKCoordinateSpan span; span.latitudeDelta = 0.1162; span.longitudeDelta = 0.1160; CLLocationCoordinate2D location; location.latitude = 65.494806; location.longitude = -23.577569; region.span=span; region.center=location; PlaceMark *add_Annotation = [[[PlaceMark alloc] initWithCoordinate:location] autorelease

iOS: MapView Annotations not showing for pins

做~自己de王妃 提交于 2019-12-10 22:49:56
问题 For some odd reason the viewForAnnotation is only working for the pin that is set in viewDidLoad (this is a test pin). The pins that are loaded elsewhere aren't getting annotated when pressed. I've already set the delegate. I think it has something to do with the identifier in the mapView call? But I'm unsure of how to fix it. Any help is appreciated! Thanks! Here's my code: import Foundation import UIKit import MapKit import CoreLocation import Alamofire class MapViewController:

How can the MKUserLocation be programmatically selected?

纵饮孤独 提交于 2019-12-10 19:37:46
问题 Titles and subtitles can be added to the user location that iOS shows using MKUserLocation. When the user taps on the location, these will show in a bubble above the location. The thought bubbles for other annotations can be shown by selecting the annotation with setSelected:animated: from MKAnnotationView. Unfortunately, MKUserLocation does not descend from MKAnnotationView. How can I programmatically select the user location so the annotation appears over the user location without the user

Center MKMapView BEFORE displaying callout

人盡茶涼 提交于 2019-12-10 18:48:57
问题 I am trying to center an MKMapView after an annotation was selected. I also have enabled canShowCallout but it seems that iOS is first displaying the callout (which is shifted when it would not fit in the screen) and then the map is being moved, resulting in the callout being not completely visible on the screen. How can I center the map BEFORE the callout's position is being rendered and displayed? 回答1: I wanted to accomplish the same thing and ended up doing the following. A word of caution

UIMapView: User location annotation is white not pulsing blue in iPad only

本秂侑毒 提交于 2019-12-10 18:09:34
问题 I've been working with maps for a while so I understand the basics of what needs to happen to show the user's location map.showsUserLocation = YES; //also have the box checked in .xib set up the locationManager - (CLLocationManager *)locationManager { if (locationManager != nil) { return locationManager; } locationManager = [[CLLocationManager alloc] init]; [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters]; [locationManager setDelegate:self]; return locationManager; } I

setRegion to encapsulate route

拈花ヽ惹草 提交于 2019-12-10 17:46:35
问题 I have a mapView in my (iOS7) app, where you can get directions from your current location to a fixed destination, by pressing a button. The app shows a polyline between the source and destination. Question is, how do i zoom the map to show the whole line? - (IBAction)handleRoutePressed:(id)sender { self.routeButton.enabled = NO; self.routeDetailsButton.enabled = NO; // Make a directions request MKDirectionsRequest *directionsRequest = [MKDirectionsRequest new]; // Start at our current