I am working on app the like Ola cabs. When the user drags map the a view transparent view appears with marker moving and when the user stops dragging the we have to centre
@interface ViewController () {
GMSMarker *marker2;
}
In viewDidLoad
marker2 = [[GMSMarker alloc] init];
// Create a GMSCameraPosition that tells the map to display the
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitude
longitude:longitude
zoom:18];
// Create GMSMapView
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
// Available map types: kGMSTypeNormal, kGMSTypeSatellite, kGMSTypeHybrid,
// kGMSTypeTerrain, kGMSTypeNone
// Set the mapType to Satellite
mapView.mapType = kGMSTypeSatellite;
mapView.myLocationEnabled = YES;
self.view = mapView;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(latitude, longitude);
marker.map = mapView;
mapView.delegate = self;
After that call delegate functions
- (void)mapView:(GMSMapView *)mapView willMove:(BOOL)gesture {
// NSLog(@"willMove");
}
- (void) mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position {
// NSLog(@"didChangeCameraPosition");
// Creates a marker in the center of the map.
// NSLog(@"%@", position);
marker2.position = CLLocationCoordinate2DMake(mapView.camera.target.latitude, mapView.camera.target.longitude);
marker2.map = mapView;
// marker2.draggable = YES;
marker2.icon = [GMSMarker markerImageWithColor:[UIColor blueColor]];
}