mkmapview

How to fetch current location in appdelegate using swift

陌路散爱 提交于 2019-12-06 14:58:46
问题 Hi am developing a app using swift i want to fetch current location of the user when app launches so i written my code in app delegate i have include all the functions and methods i.e.. added and imported frameworks core location and also updated plist but i cant able to fetch current location code in my app delegate: import UIKit import CoreLocation import MapKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate,GIDSignInDelegate,CLLocationManagerDelegate { var

MapView: Use MKUserTrackingBarButtonItem to toggle map tracking state

筅森魡賤 提交于 2019-12-06 14:47:46
问题 I have added a MKUserTrackingBarButtonItem to my toolbar. But, clicking it does nothing. So, I assumed I need to use addTarget like a normal UIBarButtonItem but that doesn't work either. How can I attach a method to that button so that I can change setUserTrackingMode:animated: ? MKUserTrackingBarButtonItem *trackingItem = [[[MKUserTrackingBarButtonItem alloc] initWithMapView:mapView] autorelease]; UISegmentedControl *segmentedControl = [[[UISegmentedControl alloc] initWithItems:[NSArray

How to pin point location in google map in XCode

谁都会走 提交于 2019-12-06 14:36:40
Hey guys, I'm building an iPhone app for my company and in one of the sections I want to create a tab bar item where it pin point the location of my company. So far I built a basic map view, but I haven't figured what would the code be for pin pointing the location of my company. hope someone can help, thanks Did you try investigating MapCallouts from Apple Sample Code? http://developer.apple.com/library/ios/#samplecode/MapCallouts/Introduction/Intro.html 来源: https://stackoverflow.com/questions/5067817/how-to-pin-point-location-in-google-map-in-xcode

Altitude problem IOS

末鹿安然 提交于 2019-12-06 14:17:56
问题 I have a problem in getting the altitude , it returns 0.0000 . Here is my code: - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSString *tAltitude = [NSString stringWithFormat:@"%f", [newLocation altitude]]; CLLocationCoordinate2D coord=newLocation.coordinate; MKCoordinateSpan span = {.latitudeDelta = 0.005, .longitudeDelta = 0.005}; MKCoordinateRegion region = {coord, span}; [map setRegion:region];

How to show single annotation pin for a region when i have multiple coordinates for that region?

和自甴很熟 提交于 2019-12-06 13:31:45
I am working on the map application and as per requirement i need to show a single pin for a single region even if it has multiple user coordinates when its completely zoomed out but when its zoomed in to the map then i should display all the pins as per its coordinates. I have given example below to explain my problem. I have city New York on this city I have 100 pins on my mapview when I am zooming out of my map it should show me only one annotation pin on the place of 100 pins but when I am zooming in then it should show again 100 pin on map. Does any one knows about this. I need suggestion

Find nearest annotations from user location ios?

六眼飞鱼酱① 提交于 2019-12-06 13:27:43
I have an array of annotations.I am calculating the distance between each annotation from user location.What I want to know is, how can I find lets say 3 nearest annotations from these distances? Here is how I am calculating distance from user location to annotations. CLLocation *userLocation = self.mapView.userLocation.location; for (Annotation *obj in annotations) { CLLocation *loc = [[CLLocation alloc] initWithLatitude:obj.coordinate.latitude longitude:obj.coordinate.longitude]; // CLLocation *userLocation = [[CLLocation alloc] initWithLatitude:self.mapView.userLocation.coordinate.latitude

MKMapView regionDidChangeAnimated called by user action or program

纵然是瞬间 提交于 2019-12-06 13:05:41
I have a MKMapView with some annotations in it. Now, every time when the region changes I load new annotations. That works fine, but if some annotation is near border of the map view and you tap on it, the annotation info window pops out and the mkmapview region moves a little (so that it can show the window nicely), but the problem is that also the regionDidChangeAnimated is called and it reloads all my annotations and of course hides the info window. I know you can just tap the annotation once again when it's reloaded but for user it seems broken and also you reload annotations when you don

Memory usage of MKMapView is very high

走远了吗. 提交于 2019-12-06 12:57:56
So i have a UIScrollView with UIPageControl which has a bunch of MKMapViews (mostly 15 different maps). The app is really sluggish once this view loads and after a few minutes of usage i get a memory warning. I looked at it in Instruments and the maps take an insanely high chunk of memory. Even upto ~200mb sometimes. One thing i can think of is to reuse the mapViews. But because of how the views are structured the coding complexity increases. Any suggestions how i can improve performance? This is how my app is structured: I have a view controller which has a UIScrollView which i use for

how can I center my map on the annotation view only when it is close to the edge of the screen?

梦想与她 提交于 2019-12-06 12:54:23
问题 In my swift application I'm using MapKit and I'm adding some annotations to the map. Currently, thanks to this question: Trying to get the span size in meters for an iOS MKCoordinateSpan I managed to create a functionality that centers my map on the annotation when user presses it. This is the code for it: let span = mapView.region.span let centerView = mapView.region.center let loc1 = CLLocation(latitude: centerView.latitude - span.latitudeDelta * 0.5, longitude: centerView.longitude) let

Custom “Callouts” for MKPolyline

随声附和 提交于 2019-12-06 12:37:09
I have an app to which I display routes on a map as MKPolyline. I made my search but I was unable to find a sample code on how to display custom MKPolyline callouts as Apple does on the ios6 maps: Can some help me? Thank you in advance.. Mindeater This appears to be The definive solution at the moment http://navarra.ca/?p=786 from this Question drawing routes on MKMapView 来源: https://stackoverflow.com/questions/16122833/custom-callouts-for-mkpolyline