Currently i am developing an app like Uber, i am using Google Maps SDK.
My issue is: At present i am showing user current location in UITextField and at the same time i display GMSMarker on Google Map also.
Now the exact what i am looking is : if user should move map (with different locations). I need to get Address for that. i don't want GMSMarker dragging functionality
When ever user move google MAP camera position i need to get that location information like: Dolly app, Uber application, Ola cabs and etc..,
Can you please help me out how can i overcome this issue
I did some R & D for this . and i got some reference links also like: Select a position using draggable map and fixed marker in Google Maps SDK for iOS
Not sure if this is what you want to achieve but:
mapView:(GMSMapView *)mapView idleAtCameraPosition:(GMSCameraPosition *)position
Reverse geocode the coordinate by using
[[GMSGeocoder geocoder] reverseGeocodeCoordinate:coordinate completionHandler:^(GMSReverseGeocodeResponse *response, NSError *error) { GMSAddress *address = [response.results firstObject]; }];
This is perfect answer for you. You see me answer...
Here you need to work on to get the current address.
Please open this link.
- (void) mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position { }
In this function we can get latitude and longitude on centre of the map.
How to move marker on the Google Map like Ola app
To get current location address
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
currentLocation = [locations objectAtIndex:0];
[locationManager stopUpdatingLocation];
CLGeocoder *geocoder = [[CLGeocoder alloc] init] ;
[geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error)
{
if (!(error))
{
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSLog(@"\nCurrent Location Detected\n");
NSLog(@"placemark %@",placemark);
NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
NSString *Address = [[NSString alloc]initWithString:locatedAt];
NSString *Area = [[NSString alloc]initWithString:placemark.locality];
NSString *Country = [[NSString alloc]initWithString:placemark.country];
NSString *CountryArea = [NSString stringWithFormat:@"%@, %@", Area,Country];
NSLog(@"%@",CountryArea);
}
else
{
NSLog(@"Geocode failed with error %@", error);
NSLog(@"\nCurrent Location Not Detected\n");
//return;
CountryArea = NULL;
}
/*---- For more results
placemark.region);
placemark.country);
placemark.locality);
placemark.name);
placemark.ocean);
placemark.postalCode);
placemark.subLocality);
placemark.location);
------*/
}];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.