1

In my iphone app I am using google map SDK for showing nearby restaurants.I am able to show the places. I have some doubts..

1. How can I find out the center coordinates of the map ??

2. How to revert back to current position ?

3.How to find out the map is moved- ie center coordinates changed(just like regionChanged delegate in MKMapView)

Saxon Druce
  • 17,406
  • 5
  • 50
  • 71
user2115266
  • 137
  • 1
  • 12

1 Answers1

2

This should probably be three separate questions, however:

1.

GMSMapView* _mapView = ...;
CLLocationCoordinate2D centre = _mapView.camera.target;

2.

GMSMapView* _mapView = ...;
CLLocationCoordinate2D currentPosition = _mapView.myLocation.coordinate;
CGFloat currentZoom = _mapView.camera.zoom;
GMSCameraPosition* camera = 
    [GMSCameraPosition cameraWithTarget: currentPosition zoom: currentZoom];
_mapView.camera = camera;

3.

Use the [mapView:didChangeCameraPosition:] delegate method.

Saxon Druce
  • 17,406
  • 5
  • 50
  • 71
  • thanks man... one more doubt...How to set the frame for mapview ? mapview.frame = CGRectMake(x,y,w,h) is not working... – user2115266 Mar 28 '13 at 04:22
  • If your map view is the root view, then it will be resized to fill the screen. Check this answer: http://stackoverflow.com/questions/15596572/google-maps-ios/15598570#15598570 – Saxon Druce Mar 28 '13 at 04:52
  • But this is not working..I add a new view and tried to add the map view in that,but the page is not getting loaded – user2115266 Mar 28 '13 at 05:38
  • Can you post the code you're using - maybe in a separate question? – Saxon Druce Mar 28 '13 at 06:07
  • Please see this - http://stackoverflow.com/questions/15675402/how-to-set-the-frame-for-mapview-in-google-gmsmap-for-ios6 – user2115266 Mar 28 '13 at 06:17