views:

256

answers:

1

I am new to iphone development.I am creating a map application.I am getting the current location and able to print the co-ordinates with %g format.What is that format.Can i save the coordinates in a integer local variable to load the current location in map. please help me out.Is there any other alternate to load the current location in device by getting its value.

NSLog(@"%g", newLocation.coordinate.latitude);
NSLog(@"%g", newLocation.coordinate.longitude);

This prints the value .but how can i save this value in integer?Please help me out.Thanks.

EDIT

double val1=newLocation.coordinate.latitude;
double val2=newLocation.coordinate.longitude;
MKCoordinateRegion region1;
region1.center.latitude=val1;
region1.center.longitude=val2;
region1.span.latitudeDelta=0.0;
region1.span.longitudeDelta=0.0;

mapView.mapType=MKMapTypeHybrid;
mapView.region=region1;

The console window

 2010-02-18 23:29:29.403 eDev[5817:207] val 1 is 37.331689
2010-02-18 23:29:29.403 eDev[5817:207] val 2 is -122.031
2010-02-18 23:29:29.404 eDev[5817:207] *** Terminating app due to uncaught    exception 'NSInvalidArgumentException', reason: 'Invalid Region <center:+37.33168900, -122.03073100 span:+0.00000000, +0.00000000>'
2010-02-18 23:29:29.404 eDev[5817:207] Stack: (
31417435,
2477657929,
31576513,
+2  A: 

The span lat/long delta cannot be zero. Try something like 0.01.

DyingCactus
That is really awesome
Warrior