adding ovelay on a map(objective c) - iphone

How to add overlay on a map in objective c?
(has any body tried it in iphone os 4.0)?

here is a good article on using the MKPolyline overlay to add a route type annotation to your map. It should give you an idea how to add any of the other overlays. just implement the
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id )overlay
on your map delegate and give it the type of overlay your are drawing.

Related

MKMapKit get visible annotationviews

How can I get all the visible MKAnnotationViews in
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)clickedview
Basically I want to make some calculation to get all the views touching (in cascade) the clickedview
thanks
You can use annotationsInMapRect: to get all the annotations inside a map rect. visibleMapRect will get you the current map rect to use.

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
}