Google Maps Locate a Place with Marker(Annotation) Code...
Link:
Install these two pods into your Project first...
pod 'GoogleMaps'
pod 'GooglePlaces'
In AppDelegate.m
#import "AppDelegate.h"
@import GoogleMaps;
@import GooglePlaces;
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[GMSServices provideAPIKey:@"AIzaSyCRmtna9ECtebYugcRCNmJHbIo-Rj4lWs4"];
[GMSPlacesClient provideAPIKey:@"AIzaSyCRmtna9ECtebYugcRCNmJHbIo-Rj4lWs4"];
return YES;
}
After installation of above pods... Add below code to info.plist Source code..
<array>
<string>googlechromes</string>
<string>comgooglemaps</string>
</array>
Now...The longitude and latitude of pace we have to give...
Add this code in ViewController.m
#import "ViewController.h"
#import <GoogleMaps/GoogleMaps.h>
#import <GooglePlaces/GooglePlaces.h>
@interface ViewController ()
@end
@implementation ViewController
// You don't need to modify the default initWithNibName:bundle: method.
- (void)loadView {
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:17.421979
longitude:78.338892
zoom:6];
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView.myLocationEnabled = YES;
self.view = mapView;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(17.421979, 78.338892);
marker.title = @"Kapil Towers";
marker.snippet = @"Hyderabad";
marker.map = mapView;
}
@end
No comments:
Post a Comment