Description to current location? - iphone

Is there a way to display some text on the blue dot alike to an annotation? Right now, it only shows "current location" when the user tap on it. I want it to act somewhat like an annotation to display current address. Where there's a title and subtitle property available to use.
I thought of replacing it with my own annotation but can't figure the way to do so.
Please advise.
Thank you

You should be able to do it by implementing mapView:didSelectAnnotationView: in MKMapView Delegate...
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
if(view.annotation = mapView.userLocation){
//reverse geocode mapview.userLocation.coordinate to get address
//then set title
}
}

Related

iphone Detect selected MKPinAnnotation in a MapView

I have a custom MKPinAnnotation in which I have added a couple of peroperties , like the Id of the object and the type. What I want is when someone selects a pin in the MapView to detect which pin is selected and get that data.
And Show a button on its view to use that data in the button's action.
Can anyone help with this? I can't find how to detect if (and which) an annotation is selected.
There is already a built in method to take care of this situation for you. You need to use the method below. The view.annotation is the annotation that was tapped.
- (void)mapView:(MKMapView *)mapView
annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(#"The annotation tapped is: %#", view.annotation.title);
}
Edit: It can be found here, the API is your friend.
https://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapViewDelegate_Protocol/MKMapViewDelegate/MKMapViewDelegate.html#//apple_ref/doc/uid/TP40008204

iOS how to keep current location center all the time

My map shows current location with blue dot..
Of course, when I move, blue dot moves.. I just want to keep blue dot center of the map all the time, making map's moving instead like Google map navigator..
I searched a lot but couldn't find the way...
In your map view delegate, do this:
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
[mapView setCenterCoordinate:userLocation.location.coordinate animated:YES];
}
Try using mapView.userTrackingMode = MKUserTrackingModeFollow;, you'll get smoother panning than using the location manager manually.
In addition note that there is a ready-made button for managing the various tracking states:
MKUserTrackingBarButtonItem.
The easiest way would be to create a new UIView on top of your map's view with a blue dot and only move the map's view.

How to present Blue circle of current location in MKMapView iphone

I have an maps application in which I show the points of interest in the map using pins. I want to represent the current location with the blue circle which is shown in Google maps. Is there any way we can add it. Can any one please help me with this. I really appreciate your time.
Thanks
You can get this by specifying nil in the appropriate delegate method:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation: (id<MKAnnotation>)annotation {
if (annotation == mapView.userLocation) {
return nil;
}
}
This should cause MKMapView to use the default, which should be the blue circle.
You should set the setShowsUserLocation: property of your map view to YES. This can be done programmatically or in Interface Builder. Be careful, as I believe the simulator still shows the user location in Cupertino, CA.
Also, if you continue tracking the user and their movements, the blue indicator will continue to move as they do.

how to handle navigation on map annotation bubble

I trying to create an application which will show some location on map. When i click on bubble with location name, i want to navigate to different view which will some information regarding the selected location
Can anyone guide me how to do that..
Thanx
#Umang why don't to you try adding a UIButton to the MKPinAnnotationView and give it a action that will be much easier. Navigate to diffetrent view by the action of UIButton......Please have a look on this tutorial and see how the UIImageView and UIButton is added to the MKPinAnnotationView
good Luck!
You can use MKMapView delegate method
- (void) mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control {
// navigate to view from here
}

MapKit problems with annotations

Ok, so I've got some issues with my MapKit annotations.
First of all, I want a callout for each annotation. I can't find out how to do this at all! :( I have two NSStrings (name of the place and a short description). Then I need to be able to log the click on the callout - so I can launch a disclosure view.
Secondly I want to change the view for the user location annotation.
At the moment all annotations are set to the "default" pin annotation view by way of this code:
- (MKAnnotationView *) mapView:(MKMapView *)myMapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:#"currentloc"];
annView.animatesDrop=TRUE;
return annView;
}
I would prefer to have the user location annotation set to the default blue pulsing circle thing, but at least I want to be able to change the pinColor property to a different color, so the user can distinguish between their own location and the results of their search.
I hope somebody can help me.
Thank you.
I think you should consider using showsUserLocation to depict your users location - it's the standard UI for the platform and helps people get a consistent experience across apps. Sure you can come up with some custom annotation for user location but why re-invent what people are used to seeing on the maps app and on many 3rd party apps?
You should take the time to review Apple's code samples for MapKit everything you need to do is there. This one in particular is a good starting point for you:
http://developer.apple.com/iphone/prerelease/library/samplecode/MapCallouts/Introduction/Intro.html
hmm... the problem was i didn't know which annotation was the one being used by current location. Its ok - I've found it now. Something like if(annotation == mapView.userlocation){ return nil; } or similar. :) Thanks for your help though