SkillAgentSearch skills...

LocationAPI

Objective-C class for finding coordinates of a location using Google Maps

Install / Use

/learn @insidegui/LocationAPI
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

LocationAPI

A simple class to get a location's coordinate using Google Maps API

Examples

Find the coordinate for Cupertino

[[LocationAPI sharedLocationAPI] coordinateForLocationNamed:@"Cupertino" callback:^(CLLocationCoordinate2D coordinate, NSError *error) {
	if (error) {
		[[[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil] show];
		return;
	}

	NSLog(@"Coordinates: %f,%f", coordinate.latitude, coordinate.longitude);
}];

Zoom to a specific location in a MKMapView

[[LocationAPI sharedLocationAPI] coordinateForLocationNamed:self.locationName callback:^(CLLocationCoordinate2D coordinate, NSError *error) {
    if (error) {
        [[[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil] show];
        return;
    }

    MKCoordinateRegion zoomRegion = MKCoordinateRegionMakeWithDistance(coordinate, 2000, 2000);

	// self.mapView is a MKMapView in this ViewController's view
    [self.mapView setRegion:zoomRegion animated:YES];
}];

Related Skills

View on GitHub
GitHub Stars5
CategoryDevelopment
Updated3y ago
Forks0

Languages

Objective-C

Security Score

55/100

Audited on Jan 28, 2023

No findings