user1680944
user1680944

Reputation: 567

Why google map doesn't load in iOS using the Google Maps API?

I am trying to integrate a Google map in my iOS application using the Google map API. However, the map doesn't want to load. I am pretty sure that I integrated the right API key, and the appropriate framework. What is wired is that I don't have the map loaded, but have the Google Logo at the bottom of the page. Here is the code of the viewController Page, and a snapshot of the execution:

#import "ViewController.h"
#import <GoogleMaps/GoogleMaps.h>


   @implementation ViewController{
   GMSMapView *mapView_;
   }


  - (void)viewDidLoad {
   [super viewDidLoad];
   // Do any additional setup after loading the view, typically from a nib.
   GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:33.53805 longitude:-5.0766 zoom:6];                                   
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    mapView_.myLocationEnabled = YES;
    self.view = mapView_;

    GMSMarker *marker = [[GMSMarker alloc]init];
    marker.title = @"Lab 7";
    marker.snippet = @"Al Akhawayn University in Ifrane";
    marker.map = mapView_;

  }

  - (void)didReceiveMemoryWarning {
   [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
  }

  @end

iOS map execution

Upvotes: 0

Views: 1006

Answers (1)

gaskbr
gaskbr

Reputation: 368

The first thing I'm seeing wrong here is the way you've created your marker. You need to inform the coordinates of it, something like this:

CLLocationCoordinate2D addressLocation = CLLocationCoordinate2DMake(self.initialLat, self.initialLong);
GMSMarker *marker = [GMSMarker markerWithPosition: addressLocation];
marker.title = @"Lab 7";
marker.snippet = @"Al Akhawayn University in Ifrane";
marker.map = mapView_;

Second thing, when you write:

mapView_.myLocationEnabled = YES;

You're telling the mapView to focus in your location, ignoring your camera coordinates you set earlier. What might be causing your beige screen with Google's logo is that the Simulator doesn't have a built-in GPS, so your localization won't show on the simulator. Try commenting that line...

That was all I could think of with this code you've posted.

Upvotes: 3

Related Questions