First of all check your Latitude and Longitude in array, it might be duplicates. Otherwise, follow steps :
At very first, add GoogleMaps.bundle
and GoogleMaps.framework
to your project.
And then when you want to implement google map, #import <GoogleMaps/GoogleMaps.h>
, then set delegate @interface YourViewController : UIViewController <GMSMapViewDelegate>
.
Declare property in your .h
@property (nonatomic, retain) GMSMapView *gMapView;
In viewDidLoad()
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:appDelegate.currentLoc.coordinate.latitude longitude:appDelegate.currentLoc.coordinate.longitude zoom:6];
self.gMapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
self.gMapView.delegate = self;
self.gMapView.myLocationEnabled = YES;
self.gMapView.mapType = kGMSTypeSatellite;
self.view = self.gMapView;
GMSMarker *curLocation = [[GMSMarker alloc] init];
curLocation.title = @"Current Location";
curLocation.appearAnimation = kGMSMarkerAnimationPop;
curLocation.position = CLLocationCoordinate2DMake(appDelegate.currentLoc.coordinate.latitude, appDelegate.currentLoc.coordinate.longitude);
curLocation.map = self.gMapView;
Where you have added multiple markers to map.
for(int i=0;i<[latLongArr count];i++)
{
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake([[(NSDictionary *)[latLongArr objectAtIndex:i] valueForKey:@"Latitude"] doubleValue], [[(NSDictionary *)[latLongArr objectAtIndex:i] valueForKey:@"Longitude"] doubleValue]);
marker.appearAnimation = kGMSMarkerAnimationPop;
marker.title = @"Title";
marker.snippet = @"Sub title";
marker.map = self.gMapView;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…