I have updated one of our testing iPad4 with iOS 7.0.4. Earlier it had iOS 6. Now in my application map view is not loading properly. We use the map to show meeting location by passing coordinates to map view. It worked fine in iOS 6. I haven't done any changes since then. I don't know what is the problem. This is the way I have done my coding.
CLLocationCoordinate2D cordinate = CLLocationCoordinate2DMake(latitude, longitude);
MKCoordinateRegion region;
region.center.latitude = latitude;
region.center.longitude = longitude;
region.span.latitudeDelta = 0.0045;
region.span.longitudeDelta = 0.0045;
[self.mapMeetingLocation setRegion:region];
[self.mapMeetingLocation removeAnnotations:self.mapMeetingLocation.annotations];
MapAnnotation *annotation = [[MapAnnotation alloc] initWithCoordinate:cordinate];
[self.mapMeetingLocation addAnnotation:annotation];
Then to check whether it is a programming issue I run the Apple's Maps app in the same iPad and it has the same issue. I searched London,England it shows screen with so many squares which is similar to the issue that I'm having in my application as well. This happens most of searches I have done with the maps. I have upload an image as well. . Is this is a bug with Apple? Please help
Related
I have developed both iPhone & iPad application which supports for iOS 5 and iOS 6
in that application i have grabbed user current location using CLLocationManager.
when i want to stop updating receiving GPS coordinates. I have called stopUpdatingLocation
method to stop calling didUpdateToLocation method. It was woking completely fine with iOS 5 and 6 But unfortunately its not working with iOS 7.
Seems that stopUpdatingLocation method is not working .Any particular reason. ??
i had a keep a variable to monitor the life cycle of didUpdateToLocation method and stop executes it.
One thing might be possible is,
Your current location blue dot moving on your map is because you set the MKMapView's showsUserLocation to YES. It will track until you set it to NO.
Second thing,
You might be setting below thing to stop calling that method
locationManager = nil;
That does not stop monitoring, but what it does, not to refer the location manager, So now its not possible to stop monitoring.
Instead add below code & then see what happen
[locationManager stopUpdatingLocation];
locationManager=nil;
Hope it helps..
#tdevoy - Here is sample
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *location = [locations lastObject];
latitude = location.coordinate.latitude;
longtitude = location.coordinate.longitude;
//stops updating current user location update
[locationManager stopUpdatingLocation];
}
I'm getting the location through - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation. It should work when you move (can't really test it in simulator, at least I don't know how) but when I first load the app, the mapview is focused on the whole world, not just my location. Can I anyhow call the method to change the location on first view?
Here is my current code if it helps:
http://pastebin.com/9Sb2xVmE
http://pastebin.com/rh9WB2ca
If your using mapkit:
Have you tried
setRegion:(MKCoordinateRegion)region animated:(BOOL)animated
Example:
CLLocationCoordinate2D coord = {latitude: 61.2180556, longitude: -149.9002778};
MKCoordinateSpan span = {latitudeDelta: 0.2, longitudeDelta: 0.2};
MKCoordinateRegion region = {coord, span};
[mapView setRegion:region];
this should zoom the mapview to your desired size, while maintaining focus on the center.
If your using CoreLocation:
Heres a checklist of what might have gone wrong:
Did you remember to import
Do you have a location manager (locationManager = [[CLLocationManager alloc] init];)
Is the code mentioned within the delegate of the location manager ?
I advise you to go to this page : Getting location of a iOS device with objective-C and follow the tutorial bit by bit. That should help you out.
Also, heres the mapkit docs
Best of luck with your project :]
we cant able to get the current location by running it in simulator. if you run the application in device it will show the correct location. In simulator it will show the default loaction as califorina(apple head quaters).
*Note this works perfectly in xcode and is only a problem on a iPhone running IOS 4.2.1
When I set the map to fit a region it does not refresh the map until I touch the screen. The bit of code I use is:
MKCoordinateRegion scaledRegion = [mapView regionThatFits:region];
[mapView setRegion:scaledRegion animated:YES];
This does move the map to the correct region which I can see when I touch the screen but until I touch the screen I get a grey screen with lots of grid lines across it.
It almost seems like the map is waiting for some sort of refresh event. I have also tried the following code with no success.
MKCoordinateRegion scaledRegion = [mapView regionThatFits:region];
[mapView setRegion:scaledRegion animated:YES];
[mapView setCenterCoordinate:mapView.region.center animated:NO];
It is also worth noting this is running in a thread.
Thanks in advance for any help.
Very weird I have turned off the animation with the following code
[mapView setRegion:scaledRegion animated:YES];
to
[mapView setRegion:scaledRegion animated:NO];
And it has started working? I do not understand why?
I currently have an application which will drop pins onto various points of interest on a map, all done programmatically on the iPhone.
What I am aiming to get done now is to allow a user to navigate to that location and get turn by turn directions by calling up the built in navigation tools on the iPhone.
Is there anyway that I can do this? I've scoured the developer center and searched both google and here and couldn't find anything about this.
You're not allowed to use google directions within your app. The only way you can do this is to send them to the google maps application as per:
- (void)getDirections {
CLLocationCoordinate2D start = { (startLatitude), (startLongitude) };
CLLocationCoordinate2D end = { (endLatitude), (endLongitude) };
NSString *googleMapsURLString = [NSString stringWithFormat:#"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f", start.latitude, start.longitude, end.latitude, end.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];
}
Been looking into this for a while today however I can't seem to get my head around how to get the users current location into a Google Maps URL to open the Google Maps app with directions populated.
I've taken this code from another tutorial and added it into my app. I need to get the "start" lat/lng from the below into my IBAction to open the Google Maps app.
- (void)locationUpdate:(CLLocation *)location {
// Lat/Lng of user (Needs to be sent to IBAction for btnDirections)
CLLocationCoordinate2D start = { location.coordinate.latitude, location.coordinate.longitude };
}
The below is my IBAction for my "Get Directions" button.
- (IBAction) onButtonClick:(id) sender {
if(sender == btnDirections) {
CLLocationCoordinate2D destination = { 52.48306771095311, -1.8935537338256836 };
NSString *googleMapsURLString = [NSString stringWithFormat:#"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f",
newLocation.coordinate.latitude, newLocation.coordinate.longitude, destination.latitude, destination.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];
}
}
I have done this previously in another app, however that view included a map showing the user location which allowed me to get the lat/lng easily.
Thanks in advance.
Simply pass "Current+Location" as a parameter to the google maps application:
http://maps.google.com/maps?saddr=Current+Location&daddr=Heathrow+Airport+London
In my code, I have an URL of the format :
http://maps.google.com/maps?daddr=%f,%f&saddr=%f,%f
(So that's 'maps' added from yours).
Other than that, you can setup your location request to stop after a set precision, did you setup precise enough for your purpose?
Oh, last note, getting current location might not work in simulator.
You need to make the user's current location available to the onButtonClick: method. You are creating the start structure on each location update, but you are never making it available outside of that method.