0

I am creating GMSMapView instance as subview in custom UIView using following code

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:position.latitude
                                                        longitude:position.latitude
                                                             zoom:CAMZOOM];

if(camera)
{
    self.googleMapView =  [GMSMapView mapWithFrame:self.frame camera:camera];
    self.googleMapView.myLocationEnabled = YES;
    self.googleMapView.delegate=self;

}

I am adding multiple UIbutton and GMSMarker to this view , which are visible without any issue but often I get map draws like below (occurs)

Incorrectly drawn GMSMapView

I have button which triggers animation to current location (refer following code), map is drawn without any issue

[self.googleMapView animateToLocation:self.googleMapView.myLocation.coordinate];

Fixed

After I removed view animation (alpha 0.0 to 1.0 with duration 1 sec) , this issue got fixed. Now my map instance loads with flicker but I can live with that.

Community
  • 1
  • 1

1 Answers1

1

Your coordinates are null so what you are seeing is blue ocean and the values are latitude = 0.0 and longitude =0.0. Try setting the coodinates manually by assigning some known value to see it it works. Eventually you need to learn how to use the delegates to read the cordinates when it becomes available.

DrBug
  • 2,004
  • 2
  • 20
  • 21
  • This resolved my issue as I hardcoded my location but I need to show current location of user which can be different place in country. I am using following code. Will it affect performance ? [self.googleMapView animateToLocation:self.googleMapView.myLocation.coordinate]; ) – hrishikesh devare Apr 23 '14 at 19:07
  • You need to implement CLLocationManagerDelegate delegate to make sure you are ready to read the device location and implement - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations where you will use self.googleMapView animateToLocation:self.googleMapView.myLocation.coordinate – DrBug Apr 24 '14 at 17:20
  • Thanks for answering my query,I have already implemented CLLocationManagerDelegate and sending valid coordinates to GMSMapView. – hrishikesh devare Apr 28 '14 at 01:41