Questions tagged [cllocationcoordinate2d]

128 questions
24
votes
2 answers

Initialize a CLLocation object in swift with latitude and longitude

In objective C (I have no experience with it) you can initialize a CLLocation object with latitude and longitude likes this: CLLocation *myLocation = [[CLLocation alloc] initWithLatitude:your_latitiude_value longitude:your_longitude_value]; But…
22
votes
1 answer

put CLLocationCoordinate2D into CLLocation for Swift

I have a method I want to call however when I get back the center of the map, it is in CLLocationCoordinate2D type. How do I put the results of CLLocationCoordinate2D into CLLocation?
13
votes
1 answer

Convert String to CLLocationCoordinate2D in swift

using Firebase as my backend, I've got a series of strings that are latitude and longitude coordinates, how can I convert them to CLLocationCoordinate2D so that I can use them for annotations? Here is the code that gets the info from Firebase every…
Learnin
  • 1,221
  • 4
  • 15
  • 19
10
votes
4 answers

How to convert latitude longitude into CLLocationCoordinate2D

I want to convert lat lon to CLLocationCoordinate2D. self.currentLocation = {.latitude = 0.0, .longitude = 0.0}; This gives me error "Expected expression". What am I doing wrong?
Harsh
  • 666
  • 1
  • 10
  • 21
9
votes
4 answers

How to get lat and long coordinates from address string

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…
Chandler De Angelis
  • 2,646
  • 6
  • 32
  • 45
8
votes
2 answers

MKPolyLine not appearing on MapView in Swift

I have the following code in Swift to add an MKPolyline to a MapView. XCode isn't telling me there's an issue, and as far as I've read, this should be working. Outlet for the MapView: @IBOutlet weak var mapView: MKMapView! Variable to hold the…
Adam Johnson
  • 673
  • 9
  • 18
8
votes
3 answers

How to give a location coordinate to plot a point in a map in ios using storyboard?

I am creating a map view in a view controller, using storyboard. When I use the following code. -(void) mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation { CLLocationDistance distance = 1000; …
chandru
  • 407
  • 1
  • 5
  • 26
7
votes
4 answers

Convert GPS coordinates to a city name / address in Swift

I have a latitude/longitude location that I want to convert to the location name String in Swift. What is the best way to do this? i believe it's best to use the reverseGeocodeLocation function but not exactly sure how to. This is what I have so…
Jeffrey G.
  • 85
  • 1
  • 1
  • 6
6
votes
2 answers

How to determine the correct altitude for an MKMapCamera focusing on an MKPolygon

I need to figure out how to set up MKMapSnapshotterOptions to take a snapshot of aerial/satellite imagery associated with a polygonal region of the earth. Filling out the 'region', 'scale', 'size', and 'mapType' properties are trivial, as I have an…
5
votes
2 answers

CLLocationCoordinate2D can't be instantiated

I am trying to create some "CLLocation"s from data that I've read from a file. The first step is to instantiate a "CLLocationCoordinate2D" to be fed into the initializer for CLLocation. I'm trying out my ideas in a Playground and this very simple…
5
votes
2 answers

Realm Object returning nil (Swift)

I have a custom polygon object so I can save map overlays to Realm. I'm able to create this objects successfully, but when I want to retrieve the var polygon object it returns nil. When I print the polygon object, it prints it out fine, with all the…
Tristan Beaton
  • 1,742
  • 2
  • 14
  • 25
5
votes
2 answers

Swift: How can I store coordinates using CLLocationCoordinate2D as a string or an int?

So far, this is the code I have. I'm trying to store the values of locValue.latitude and locValue.longitude as either a string or an integer. I've tried defining the return type in the method ( -> String, etc.) but I get an error saying the…
J. Cal
  • 157
  • 1
  • 3
  • 18
4
votes
1 answer

CLLocationCoordinate2D into one array

I have a dynamic amount of locations being plotted onto a mapkit. I am curious on how I can get my current latitudes and longitudes into a single array, as they are currently being printed as separate objects which is not plotting not the map like…
3
votes
2 answers

Reverse function of MKCoordinateRegionMakeWithDistance?

MapKit's built in function MKCoordinateRegionMakeWithDistance takes distances in meters and turns them into a MKCoordinateRegion: func MKCoordinateRegionMakeWithDistance( _ centerCoordinate: CLLocationCoordinate2D, _ latitudinalMeters:…
3
votes
1 answer

How to Fix: Cannot assign value of type 'CLLocationDegrees' (aka 'Double') to type 'Float!' in Swift 3

I get a coordinate from my google map and I want to assign it to a float variable, but it shows this error: Cannot assign value of type 'CLLocationDegrees' (aka 'Double') to type 'Float!' func markerButtonClicked(sender:MapButton) { let…
reza_khalafi
  • 6,230
  • 7
  • 56
  • 82
1
2 3
8 9