1

I am getting co-ordintes from user in UITextFields. He enters them in degrees,minutes and seconds. I get the latitude and longitude from them after conversion. I set the coordinates and "build" a map. This builded map view I add it to the UIViewController as subview.

CLLocationCoordinate2D location = CLLocationCoordinate2DMake(finalLatValue,finalLongValue);
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(location, LOCATION_DISTANCE, LOCATION_DISTANCE);
MKMapView *mvMap = [[MKMapView alloc] initWithFrame:CGRectMake(20,594,360,347)];

mvMap.mapType = MKMapTypeSatellite;
mvMap.autoresizingMask = UIViewAutoresizingNone;
mvMap.region = region;
[mvMap setRegion:region animated:YES];
//mvMap.showsUserLocation = YES;
[self.view addSubview:mvMap];

So as you can see I create a location using finalLatValue and finalLongValue.Then I create a map and adding it to the self.view as a subview. It works perfectly. Now all I need is a blue dot on that location. I did setRegion:animated and showUserLocation..Both did not work.What am I missing? The idea is for the user to enter co-ordinates in Degrees,minutes and seconds and show the location on the map with a blue dot.CGRectMake(20,594,360,347) just creates my map view at the bottom left side of the view,as I have buttons and labels all over my view. If more information is needed please ask.Thanks..

MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc]init];
annotationPoint.coordinate = location;
annotationPoint.title=@"Company";
annotationPoint.subtitle = @"Company HQ";
[mvMap addAnnotation:annotationPoint];

So i added these lines and now my location shows a red pin. That will do for now. Now i have question about zoom in and zoom out of the map-view with pinch. How can i do it?Any help will be appreciated. I have more questions.

RookieAppler
  • 1,517
  • 5
  • 22
  • 58

2 Answers2

1

There is a good documentation from Apple

The LocationAwareness Programming Guide

http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/LocationAwarenessPG/MapKit/MapKit.html

There you find under chapter Anotations:

The blue dot is called 'UserLocAnnotation`` (or similar)

AlexWien
  • 28,470
  • 6
  • 53
  • 83
  • Thanks. I saw the tutorial and got a annotation point and used it and now my map shows location with a red dot. I have another question about zoom in zoom out. How can i use the map like google maps and zoom in and zoom out. Is that facility present?If so, how? – RookieAppler Nov 27 '12 at 00:07
  • Yes, Zoom by User is automaticakly inclusive. Programmaticalky Zoom is a Bit if work, but Not dufficult. – AlexWien Nov 27 '12 at 01:59
  • The red Point is a fixes Location like Point of interesse, the UserlocationAnnotation is the Blue dot. Read that docu, you will find it. – AlexWien Nov 27 '12 at 02:01
  • Wien. Thanks. I got it. Yes, the red point is the location of the user wants to go. Not his current location. Though i am still not able to get it.As soon as the app launches we should get his co-ordinates in either degree,minutes seconds or lat/long and a blue dot. Can you give me a an example?I also got the zoom in and out to work.It was pretty easy.Fun!!! I had 3 issues to begin. 1.show a location(NOT user location) with a red point-Done.2.Zoom in zoom out -Done 3.User location with a blue dot- Not Done.The 3rd one i am not getting.Help me. – RookieAppler Nov 28 '12 at 02:49
0

Calling showsUserLocation will show the user's location, but you're asking for help showing a blue dot at the coordinates the user has entered, which may not be the at their current location.

What you want to do is add an MKAnnotation to your map. As AlexWien said, Apple has got very complete documentation on the subject. This link will walk you through the process of making the MKAnnotation and setting its location, then defining what image the map will draw at that place

http://developer.apple.com/library/ios/documentation/userexperience/conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html#//apple_ref/doc/uid/TP40009497-CH6-SW1

Craig
  • 8,093
  • 8
  • 42
  • 74
  • Thanks. Yes i got confused between blue and red dots. I now have a red dot at the location, which is NOT the user current location. I can work with it. I have a question with regards to zoom in and zoom out feature. Can i zoom in and out on the mapview like google maps. A '+' and '-' on the mapview to zoom in and zoom out respectively. – RookieAppler Nov 27 '12 at 00:09
  • You should file a new question for that, or just search for existing questions that ask exactly the same thing: http://stackoverflow.com/questions/1031787/zoom-in-a-mkmapview-programmatically – Craig Nov 27 '12 at 00:17