mapkit

Write data to plist

怎甘沉沦 提交于 2019-12-05 21:52:32
I would like to read data from a plist, add some elements and the write the data to a plist.(update a plist). I want to have the plist hold an array of dictionaries, read this array into my app, add dictionaries and then write the array back to the plist. How is this done? Im also not sure where and how to create the plist on the apps first launch. or should it be placed in the bundle from the beginning? Another thing I am not sure about is if the plist dictionaries can hold e.g. CLLocations as values for keys? Will it be saved correctly or would the CLLocation need to be broken into lat and

How to get lat and long coordinates from address string

自闭症网瘾萝莉.ら 提交于 2019-12-05 21:46:11
问题 I have a MKMapView that has a UISearchBar on the top, and I want the user to be able to type a address, and to find that address and drop a pin on it. What I don't know is how to turn the address string into longitude and latitude, so I can make a CLLocation object. Does anyone know how I can do this? 回答1: You may find your answer in this question. iOS - MKMapView place annotation by using address instead of lat / long By User Romes. NSString *location = @"some address, state, and zip";

Swift: Reduce Function with a closure

放肆的年华 提交于 2019-12-05 21:23:59
Below is the code that I'm struggling to understand: let rectToDisplay = self.treasures.reduce(MKMapRectNull) { //1 (mapRect: MKMapRect, treasure: Treasure) -> MKMapRect in //2 let treasurePointRect = MKMapRect(origin: treasure.location.mapPoint, size: MKMapSize(width: 0, height: 0)) //3 return MKMapRectUnion(mapRect, treasurePointRect) } My understanding of reduce function is: var people [] // an array of objects var ageSum = 0 ageSum = people.reduce(0) { $0 + $1.age} //(0) = initial value //$0 = running total //$1 = an object in an array My understanding of closure is: { (params) ->

Reverse function of MKCoordinateRegionMakeWithDistance?

走远了吗. 提交于 2019-12-05 18:34:21
MapKit's built in function MKCoordinateRegionMakeWithDistance takes distances in meters and turns them into a MKCoordinateRegion : func MKCoordinateRegionMakeWithDistance( _ centerCoordinate: CLLocationCoordinate2D, _ latitudinalMeters: CLLocationDistance, _ longitudinalMeters: CLLocationDistance) -> MKCoordinateRegion is there a reverse function that takes a MKCoordinateRegion and gives me latitudinalMeters and longitudinalMeters? MKCoordinateRegion gives a center (latitude and longitude) and span (delta latitude and longitude). Given these values, you can determine the location of the edges

iOS: How to convert MKMapPoint or CLLocationCoordinate2D to UTM?

亡梦爱人 提交于 2019-12-05 17:06:04
From what I have read this takes some complicated Math that I am not good at. So, I am asking here. Does anyone have experience converting a MKMapPoint or CLLocationCoordinate2D to a UTM value? I found this resource ( http://www.uwgb.edu/dutchs/usefuldata/UTMFormulas.HTM ) but the math is overwhelming. You could use one lib to do that, or analyze the code of one lib to understand the algorithm and do it yourself. This is a c++ lib that does the job: http://geographiclib.sourceforge.net/html/ http://geographiclib.sourceforge.net/html/classGeographicLib_1_1UTMUPS.html I found this website (http:

Calculating heading of compass to a specific coordinate instead of to north

守給你的承諾、 提交于 2019-12-05 13:59:33
I can't get this algorithm right. I'm trying to make a compass that points at a certain location instead of just pointing to, let's say, north. Something is wrong. I've spent a lot of time trying to figure this out, but i just can't find it. Any ideas? - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading{ double distanceEast = (location.longitude > 0 && otherLocation.longitude < 0) ? 180 - location.longitude + otherLocation.longitude - -180: otherLocation.longitude - location.longitude; if (distanceEast < 0) { distanceEast += 360; } double distanceWest

iOS 6 Map doesn't zoom with MKUserTrackingModeFollow

夙愿已清 提交于 2019-12-05 12:23:49
While my iOS6 MKMapView is in MKUserTrackingModeFollowWithHeading or MKUserTrackingModeFollow , zoom gestures (pinch, double-tap, two-finger tap) work sometimes, but not always. The issue seems to occur when didUpdateUserLocation: is called after regionWillChangeAnimated and before regionDidChangeAnimated . Any ideas on how to fix this? To isolate the problems, I've created a Single View Application with an MKMapView and a UIToolbar (set up in a .xib), to which I'm adding a MKUserTrackingBarButtonItem . The UIViewController acts as a <MKMapViewDelegate> . Here's the complete implementation

ios 7 MKMapView draggable annotation change it's position when map is scrolled

偶尔善良 提交于 2019-12-05 11:17:34
I am updating my app (MyWorld) to iOS 7. One of the features of the app is that you can drag pin on the map view. It seems to be broken in iOS7. Steps to recreate the problem: Adding Annotation to the map: - works fine Moving Annotation (Dragging) works fine Scrolling the map: Problem Whenever I scroll the map view annotation is moved with the map. It seems like it's not attached to the right view or layer?? If the pin is not dragged map view seems to work fine and annotation stays in defined position. I wonder if this is a mistake on my side or a known issue? I created a dummy MapViewTest

MKMapView tiles not loaded with zoom

青春壹個敷衍的年華 提交于 2019-12-05 08:28:57
I've got an issue. I'm using a MKMapView for displaying some annotations. I initialize a map view with default zoom. And it displays some map. but when i try zooming, tiles not loaded, and map becomes empty. Like this. I create my Map View via interface builder. @property (nonatomic, weak) IBOutlet MKMapView* mapView; What am I doing wrong? Is there any mandatory methods for implementation, that affect on this functional? And yes, there is an internet connection on my device. Generally this can happens due to internet connection. If you have slow internet connection than it takes time to load

using CLLocation objects as keys in dictionary

谁说我不能喝 提交于 2019-12-05 07:55:21
Is it possible to use CLLocation objects as keys in a dictionary? When I try this, the [dictionary objectForKey: clLocationObj] always returns nil even when there are CLLocation keys already inserted with exactly the same latitude and longitude. What could I be doing wrong? for (Location *location in someArray) { CLLocation *locationKey = [[CLLocation alloc] initWithLatitude:[location.latitude doubleValue] longitude:[location.longtitude doubleValue]]; LocationAnnotation *annotationAtLocation = [self.uniqueLocations objectForKey:locationKey]; if (annotationAtLocation == nil) NSLog(@"this is