I am trying to implement my current location within a sub view using Google Map SDK for IOS
. I am trying to implement the GMSMapView as an IBOutlet.
My header file has the code
#import <UIKit/UIKit.h>
#import <Google-Maps-iOS-SDK/GoogleMaps/GoogleMaps.h>
@interface TripLandingViewController : UIViewController
@property IBOutlet GMSMapView *mapView;
@end
My .m file has the code
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Tile.png"]];
self.mapView.myLocationEnabled = TRUE;
NSLog(@"\n\n\n My Location is %f,%f \n\n\n",self.mapView.myLocation.coordinate.latitude,self.mapView.myLocation.coordinate.longitude);
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:self.mapView.myLocation.coordinate.latitude
longitude:self.mapView.myLocation.coordinate.longitude
zoom:10];
self.mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
No matter, what hardcoded value i provide as parameters for coordinates in camera. I am getting the wrong location (here UK) which is not at all updating.
But Instead when i tried
self.View = [GMSMapView mapWithFrame:CGRectZero camera:camera];
I was able to load correct map View in the Main View with correct location coordinates.
I tried all the answers on adding Google Map to SubViews through stackoverflow.
Cannot put a google maps GMSMapView in a subview of main main view?
How to set the frame for mapview - in google GMSMap for iOS6
How put Google MapView in UIView?
Google Maps iOS SDK, Getting Current Location of user
But nothing seems to work. Please Help since I am new to IOS Programming.