我从iOS中删除了地图并切换到谷歌地图。现在它显示了我的位置,但它没有加载地图。它是灰色/黄色,位于Google的左下角。
这是我的实施:
#import <CoreLocation/CoreLocation.h>
@interface GoogleMapViewController ()
@property (strong, nonatomic) CLLocationManager *locationManager;
@end
@implementation GoogleMapViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
_mapView.myLocationEnabled = YES;
self.view = _mapView;
[self initLocationManager];
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = _mapView;
}
- (void) initLocationManager
{
self.locationManager = [[CLLocationManager alloc] init] ;
self.locationManager.delegate = (id)self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation ;
[self.locationManager setDistanceFilter:10.0f] ;
[self.locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSLog(@"New locations");
[self.locationManager stopUpdatingLocation];
_mapView.camera = [GMSCameraPosition cameraWithTarget:newLocation.coordinate
zoom:6];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
这基本上是Google Dev页面的教程演示应用程序,我不确定为什么它没有加载地图。
这就是我得到的:
答案 0 :(得分:0)
我发现了问题。您需要将初始摄像机缩放级别设置为1,然后放大当前位置。这样你仍然可以缩小并拥有整个地图。
如果您将缩放级别14作为初始值,那么谷歌地图并不会加载我认为的地图的其余部分。