I Am using googlemapssdk in my app instead of mapkit,how I have a text field I have to use that textfield for searching places in the google maps.
How to use text for searching places in the googlemaps sdk and how to get the searched place latitude and longitude of that particular place.
I have gone through all the questions in the stack overflow but I can't able to understand them so please help me out to solve this problem.
Thanks for quick Answers.
//You can perform search by tapping search button using the following code
- (IBAction)searchButtonPressed:(id)sender {
[self searchForLocationWithText:self.searchTextField.text];
}
//Else If you want to perform the search on typing each letter, You can use this delegate method
- (void)textFieldDidChange:(NSNotification *)notification {
[self searchForLocationWithText:self.searchTextField.text];
}
//Method for searching
- (void)searchForLocationWithText:(NSString *)searchString{
GMSCoordinateBounds *bounds = [self getGMSBoundsWithRadiusInMeters:10000];
GMSAutocompleteFilter *filter = [[GMSAutocompleteFilter alloc] init];
filter.country=#"IN";
[place_client autocompleteQuery:searchString bounds:bounds filter:filter callback:^(NSArray *results, NSError *error) {
//Process result
}];
}
Related
I am building a map-based app in iOS (Objective-C) using HERE maps, and am new to this. I was successful in implementing navigation but I am facing a hitch in implementing voice instruction for navigation. This is the code that I have:
- (void) beginNavigationMethod {
self.mapView.zoomLevel = 17.0;
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(didUpdatePositionForNavigation) name:NMAPositioningManagerDidUpdatePositionNotification object:[NMAPositioningManager sharedPositioningManager]];
NMAVoiceCatalog *voiceCatalog = [NMAVoiceCatalog sharedVoiceCatalog];
voiceCatalog.delegate = self;
[voiceCatalog updateVoiceCatalog];
[self.navigationManager startTurnByTurnNavigationWithRoute:self.route];
[NMANavigationManager sharedNavigationManager].mapTrackingEnabled = YES;
[NMANavigationManager sharedNavigationManager].mapTrackingAutoZoomEnabled = YES;
[NMANavigationManager sharedNavigationManager].mapTrackingOrientation
= NMAMapTrackingOrientationDynamic;
[NMANavigationManager sharedNavigationManager].speedWarningEnabled = YES;
NSError* error = [[NMANavigationManager sharedNavigationManager] startTurnByTurnNavigationWithRoute:self.route];
NSLog(#"%#",error);
}
- (void)voiceCatalog:(nonnull NMAVoiceCatalog *)voiceCatalog didUpdateWithError:(nullable NSError *)error {
NSLog(#"didUpdateWithError: %#",error);
}
I basically don't know how to proceed with this. My apologies for being so naive. If anyone could guide me through this, it would be a great help.
You can look at docs: https://developer.here.com/documentation/ios-premium/topics/map-voice-instructions.html
Otherwise, where is an example for Android: https://github.com/heremaps/here-android-sdk-examples/issues/36#issuecomment-304873154, if you can go through it it will give you an impression of how to do that.
Please try this code
[[NMANavigationManager sharedNavigationManager] setVoicePackageMeasurementSystem:NMAMeasurementSystemImperialUS];
[[NMAAudioManager sharedAudioManager] setDelegate:self];
[[NMAAudioManager sharedAudioManager]setManagesAudioSession:NO];
Here Map Delegate Method
- (BOOL)audioManager:(NMAAudioManager *)audioManager shouldPlayOutput:(NMAAudioOutput *)output{
return true;
}
Project Setting->General->Capabilities->Background Modes
//import contacts by using contact picker
CNContactPickerViewController *contactPicker = [CNContactPickerViewController new];
contactPicker.delegate = self;
NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:#"phoneNumbers.#count >= 1"];
contactPicker.predicateForEnablingContact = filterPredicate;
[self presentViewController:contactPicker animated:YES completion:nil];
- (void) contactPicker:(CNContactPickerViewController *)picker
didSelectContacts:(NSArray<CNContact *> *)contacts {
//code for selecting multiple contacts
}
-(void)contactPickerDidCancel:(CNContactPickerViewController *)picker {
NSLog(#"Cancell");
}
I am using the above code to import the contacts, i am able to import the contacts. But i need to remove the searchbar from the CNContactPickerViewController. I have already tried the below solution provided in the stack overflow but its not working. Any help will be really appreciated.
How to hide/Remove the search bar on Contact Picker
As the CNContactPickerViewController is a UIRemoteView you have no access to it. As such this is not possible.
Am adding custom overlays to MKMapView and need to clear the map content before adding overlay (i.e when zoomed or panned default map should be invisible)
Something similar to "canReplaceMapContent" in IOS7 and later.
Is there any method to perform this action in IOS6?
Thanks in advance.,
You method below:
- (void) removeMapOverlay {
[self.mapView removeOverlays:[self.mapView overlays]];
NSMutableArray *tempArray = [NSMutableArray arrayWithArray:[self.mapView annotations]];
if ([tempArray containsObject:[MKUserLocation class]]) {
[tempArray removeObject:[MKUserLocation class]];
}
NSArray *annotationArray = [NSArray arrayWithArray:tempArray];
tempArray = nil;
[self.mapView removeAnnotations:annotationArray];
}
Edit:
When you pinch/zoom or pan in the map. There are two delegate methods are available you can use to check map is loading or not?
- (void)mapViewWillStartLoadingMap:(MKMapView *)mapView {
NSLog(#"loading...");
}
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView {
NSLog(#"Map loaded...");
}
What i suggest you to use above two methods. Create a bool variable or some means not to load annotations when zoom. How ever i'll keep update if there is other simple way to do it.
You could draw a custom, opaque overlay on top of Apple's maps, but there is still a very slight chance that you will see the map beneath from time to time. I'd recommend an alternative, open source toolset that you can control like Mapbox for complete control.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I have a UITextField and I would like to create something a bit like the drop down menu in the ios contact app.
When the user starts typing, I would like the menu to drop down. It doesn't really need to limit the data it shows based on what the names but it would be great if it could (ex: it if the user types "m" it only shows strings beginning with m and so on). If the user selects one, that type would be sent to the UITextField where it would be displayed. If there is any open source picker like this, it would be great. If not, is there a way to present something like that that contains all items from the array. This would not have to be complex, it wouldn't have to limit the data shown when the user types or anything.
Response based on this link. Will show you how to get URL values in a dropdown that will autocomplete.
You need to have an NSMutableArray with the possible autocomplete values. In this example, we’ll use an NSMutableArray of pastURLs, and every time the user browses to a URL we’ll add it to the array.
You need to create a UITable to show the values
autocompleteTableView = [[UITableView alloc] initWithFrame:
CGRectMake(0, 80, 320, 120) style:UITableViewStylePlain];
autocompleteTableView.delegate = self;
autocompleteTableView.dataSource = self;
autocompleteTableView.scrollEnabled = YES;
autocompleteTableView.hidden = YES;
[self.view addSubview:autocompleteTableView];
You need to show the table when the field is being edited
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
autocompleteTableView.hidden = NO;
NSString *substring = [NSString stringWithString:textField.text];
substring = [substring stringByReplacingCharactersInRange:range withString:string];
[self searchAutocompleteEntriesWithSubstring:substring];
return YES;
}
And finally only show stuff in the table that is being edited
-(void)searchAutocompleteEntriesWithSubstring:(NSString *)substring {
// Put anything that starts with this substring into the autocompleteUrls array
// The items in this array is what will show up in the table view
[autocompleteUrls removeAllObjects];
for(NSString *curString in pastUrls) {
NSRange substringRange = [curString rangeOfString:substring];
if (substringRange.location == 0) {
[autocompleteUrls addObject:curString];
}
}
[autocompleteTableView reloadData];
}
Don't forget to add the proper UITable and UITextfield delegates to your .h file.
Hy :)
I am trying to update in background the position of the device (iPhone) and it works with the simulator http://grab.by/meLq (the annotations are only added in Background).
But when I am testing with my iPhone it does not work, I have got a line between the last position (before being in background) and the position when the becomes active.
What about the coding ?
I made a test of making a list when the app is in background and when the application becomes active again I load the list of positions recorded. (work with the simulator)
- (void)handleAddLocations {
NSLog(#"%s | %#", __PRETTY_FUNCTION__, self.locationBackgroundList);
if ([self.locationBackgroundList count] > 0) {
for (CLLocation *backgroundLocation in self.locationBackgroundList) {
if (YES){
LocAnnotation* annotation = [[LocAnnotation alloc] initWithCoordinate:backgroundLocation.coordinate];
NSLog(#"%s %#", __PRETTY_FUNCTION__, [annotation description]);
[self.mapView addAnnotation:annotation];
}
MKUserLocation *userLocation = [[MKUserLocation alloc] init];
[userLocation setCoordinate:backgroundLocation.coordinate];
[self mapView:self.mapView didUpdateUserLocation:userLocation];
}
[self.mapView updateConstraints];
[self.locationBackgroundList removeAllObjects];
self.locationBackgroundList = [[NSMutableArray alloc] init];
}
}
Thanks for helping ;)
Its a better option to add the annotation by creating a list in of locations in background.This is not possible to manage uielements when the app is in background.For this you should add all the positions in array while yous app is in background.