In my app i need a map to loaded by passing address,city, state province code and postal code.
Can any one tell me how can i do it??
You can use below :-
NSString* yourFullAddress = #"address,city, state province code and postal code";
yourFullAddress = [yourFullAddress stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
// Now create the URL string ...
NSString* urlString = [NSString stringWithFormat:#"http://maps.google.com/maps?q=%#", yourFullAddress];
// An the final magic ... openURL!
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
Or in case u dont want to open google maps and rather set the coordinates on ur MKMapView ... u can GeoCode ur address to get the coordinates and finally set the coordinate region on ur MKMapview ..
Did you even try searching on Google or SO?
A good start would be here http://blog.objectgraph.com/index.php/2009/04/02/iphone-sdk-30-playing-with-map-kit/
Related
I want to do the following. I have an array of objects (businesses) and each business has its own details including their telephone numbers.
I know how to make a call in Objective-C but I don't know how to update the numbers dynamically. I have a Details class (.h and .m) and I have declared tel as a variable.
So to make a call I would use below as an example
-(IBAction)MakePhoneCall:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:123456"]];
}
I use a DetailViewController so I have a list of businesses that gets populated and depending on the business selected, that business object is created. So for my tel I want to do the following:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:" + detail.tel]];
But this obviously doesnt work. Can anyone please tell me how this is done?
if you're making a call from your application and you want the user back into the application after the end of the call then use telprompt: instead of tel: like below
-(IBAction)MakePhoneCall:(id)sender
{
NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:#"telprompt://%#",detail.tel]];
[[UIApplication sharedApplication] openURL:URL];
}
I would create a [NSString stringWithFormat], then plug that in the "URLWithString".
-(IBAction)MakePhoneCall:(id)sender
{
NSString *string = [NSString stringWithFormat:#"tel:%#", detail.tel];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:string];
}
Hope that helps.
Hi, i am working on GPS ios app.
I want to display user's location on Circle as shown in image.
The user is in center.
I want to display his friend's location on proper direction.
I had already got langitude and latitude of both user .
But how can i get other user's direction?
If can i use Bearing angle?
I get the Distance between two uses by this code
CLLocation *locA = [[CLLocation alloc] initWithLatitude:Latitude longitude:Longitude];
CLLocation *locB = [[CLLocation alloc] initWithLatitude:app.lat longitude:app.lag];
CLLocationDistance distance = [locB distanceFromLocation:locA];
Thanks for Help!!
You can do it using two ways :
1.
CLLocationCoordinate2D start = { c_lat, c_long };
CLLocationCoordinate2D destination = { [[dic valueForKey:#"business_lat"]doubleValue], [[dic valueForKey:#"business_long"]doubleValue] };
NSString *googleMapsURLString = [NSString stringWithFormat:#"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f&",start.latitude, start.longitude, destination.latitude, destination.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];
2.
Using Google API
In API you just need to pass origin name and destination name
Hope this helped....
This question describing how to compute bearing using the haversine function
i am making an application which has a feature that allows users to create location based notifications to turn the application on/off when they arrive/leave a certain location.
Reminders are created (as indicated by the first picture), but are not triggered upon arriving/leaving.
If on the other hand the user click on the reminder, it kind of adds the address (shown on picture number 2) and is from there on triggered
I was wondering if there is a way to make the Reminder app recognize the address or any other suggestion, that might help me in solving this peculiar problem.
Thank you in advance,
BR,
Rok
The code that i use is:
EKReminder *reminder = [EKReminder reminderWithEventStore:_eventStore];
reminder.calendar = [_eventStore defaultCalendarForNewReminders];
EKStructuredLocation *location;
NSError *error = nil;
EKAlarm *alarm = [[EKAlarm alloc]init];
reminder.title = #"Turn off Test App";
location = [EKStructuredLocation locationWithTitle:self.addressTextField.text];
[self.addressTextField resignFirstResponder];
alarm.proximity = EKAlarmProximityEnter;
alarm.structuredLocation = location;
[reminder addAlarm:alarm];
[_eventStore saveReminder:reminder commit:YES error:&error];
The problem is that you are failing to set your EKStructuredLocation's geolocation and radius. All it has is a title. That isn't enough to tell the alarm where on earth it is supposed to be!
Example:
location.geoLocation =
[[CLLocation alloc] initWithLatitude:latit longitude:longit];
location.radius = 10*1000; // metres
See CLLocationManager -startMonitoringForRegion:, and the CLRegion class reference.
Using MapKit in iOS 6, how am I'm supposed to get nearby locations without having their specific coordinates? I'm also unsure if it's still possible...err...allowed...to use Google Maps API to accomplish this goal, as this is the only way I can think of to do this. I know everything is still in beta, but I've still found no information anywhere about this topic, on forums, in Apple's new MapKit Documentation, anywhere. All I want to do is perform a search for locations (let's say, parks, for example) within 'x' miles of the user's location.
It seems that since Apple has developed their own Maps application, they should have a way to accomplish this using MapKit or Core Location...right?
Try with this code. This may help to you.
URLManager *urlmanager = [[URLManager alloc] init];
urlmanager.delegate = self;
urlmanager.responseType = JSON_TYPE;
urlmanager.commandName = #"Search";
NSString *locationString = [NSString stringWithFormat:#"%f,%f",latitude,longitude];
//Location where you want to search
NSString *key = #"AIzaSyCNRpero6aM451X0IfgFHAd-Y3eJUssqoa8`enter code here`0E";
//This is the secret key which you will get from the Google API Console when you register your app.
NSString *radiuos = #"15000";
//This is the area within which you want to search
NSString *keyword = #"Hotel";//Search keyword you want to search
NSMutableDictionary *arguments = [[NSMutableDictionary alloc] init]; // zero argument
[arguments setValue:key forKey:#"key"];
[arguments setValue:locationString forKey:#"location"];
[arguments setValue:radiuos forKey:#"radius"];
[arguments setValue:#"true" forKey:#"sensor"];
[arguments setValue:keyword forKey:#"keyword"];
NSLog(#"Arguments are %#",arguments);
[urlmanager urlCallGetMethod:[NSString stringWithFormat:#"https://maps.googleapis.com/maps/api/place/search/json"] withParameters:arguments];
I am trying to get the google places API to work on my iPhone project. Now, I had it working about an hour ago, but I can't seem to figure out what I did to make it stop working. Any help would be appreciated.
Here is what I have so far:
- (NSString *)searchString {
// this mutable string allows me to dynamically create the search string
// we start with the static part of the api search URL
NSMutableString *result = [NSMutableString stringWithString:#"https://maps.googleapis.com/maps/api/place/search/json?location="];
// since I need to get the user's location, I need to create a location manager
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
// we need to now update the current location,
// otherwise there will be no coordinates
[locationManager startUpdatingLocation];
// now that it's updated, we stop it because I
// am not tracking anything
[locationManager stopUpdatingLocation];
// this appends the lattitude/longitude, as double values, into the URL
[result appendFormat:#"%g,%g", [[locationManager location] coordinate].latitude, [[locationManager location] coordinate].longitude];
// release the location manager for memory management
[locationManager release];
// if a filter is present, add the keyword item to try to filter
// the results
if([[self filterString] length] > 0) {
[result appendFormat:#"&keyword=%#", filterString];
}
// add the rest of the validated URL now
//[result appendString:#"&types=food|meal_delivery|meal_takeaway|restaurant&rankby=distance&sensor=true&key=AIzaSyBmO_f6h4_Q0xArw6tdxUF7TH7rZpaiFfQ"];
[result appendString:#"&types=food&rankby=distance&sensor=true&key=mykey"];
// log the result for testing
NSLog(#"Completed Search String: %#", result);
return result;
}
Now, when I look at my log, copy the 'completed search string' into Safari, it brings up the results that I need.
But if I use the following code, the app hangs:
- (void)performSearch {
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[self searchString]]]; // hangs on this line!
NSDictionary *jsonDictionary = [data objectFromJSONData];
NSArray *resultsArray = [jsonDictionary objectForKey:#"results"];
currentList = [ARGooglePlace placesWithArray:resultsArray];
[self.tableView reloadData];
}
I think I should mention that I am using the JSONKit to do the JSON parsing. Also, the ARGooglePlace is a custom class that isn't relevant right now (it doesn't even get there...)
Thanks for any help that you can provide.
Pull the location manager and the lat/long out of the searchString method... just put it in the performSearch method. And instead, pass the lat/long as received from location manager into searchString.
It sounds like a timing issue with your location manager. It could have been working earlier b/c location manager had previously cached location data... and was able to grab the correct coords.
2+ Possible scenarios:
1) problem with location manager not updating it's coords and just hanging there
2) google website being the culprit (maybe loading too much data??)
Pulling location manager out of the searchString method will help isolate cause... and one can just pass lat/long values directly to test google website as well.