return to apple maps at different zoom - ios

I have a map of a zoo with pins that locate the animals. Zoom on the map. Tap on a pin then tap callout and it takes the user to a view with pic of animal and description/narrative. The "map" button on that view returns the user to the zoo map at the original zoom level. Does anyone know of a way to return to the map at the last zoom level/location?

You can set what the region of what the user can see when your map gets displayed by using the
[self.mapView setRegion:adjustedRegion animated:YES];
function. So what you want to do is, save the "region" property just when the map view is about to disappear so that you can set it again when the map view appears.

Related

Show custom and default callout views on different pins with pin clustering on map view

This is my first question, and i am new to iOS.
I am implementing pin clustering on map view , which in working fine for one type of pin but my requirement is to cluster different kind of pins with different cluster count on it when zoomed out i.e if one kind of pin shows river details on map view than these pins should cluster together and give a count on it and on other case if other pin is showing details for diversion on map view than these pins should cluster together separately from river pin and give a separate count on it. and this same case is followed for other 4 different kinds of pins.
And i have one more issue , how to implement different callout views for these above different kind of pins on same map view i.e suppose river pin have default callout which includes title,subtitle and accessory button. And on other side for Diversion pin i have my own custom call out view . So now i want is when i tap on river pin than default callout should pop out and when i tap on diversion pin than my own custom callout should pop out.And same for other kind of pins too.
Please help me out . I am working on these issues from last 2 weeks but nothing working out for me. Please help me out i want a solution for these problems badly.
NOTE: The custom callout and default callout should be implemented with pin clustering.
I have created a demo, which will solve your problem about custom call out and default call out.
Answer
will guide you how to create custom call out and add pins for it.
This code contains PinAnnotation which is a subclass of MKAnnotation and acts to show custom call out.
For the default call out view you just have to add MKAnnotation to map and it will show default one.
How ever you can customise it if you want and create another sub class for it.
To test default call out with custom call out view. Download demo project from that answer link or directly from here.
Add below code at the end of viewDidLoad() and run the application.
MKPointAnnotation *pin = [[MKPointAnnotation alloc] init];
pin.coordinate = CLLocationCoordinate2DMake(34.65515f, 133.81951f);
pin.title = #"Default Pin";
[self.mapView addAnnotation:pin];
It will be looks like below:

How to fix the annotation image on map view?

I am working on app which will show the current user location on map.I am using the custom annotation on map view for example a car image.I am rotating this image by finding the angle between two locations.But whenever user rotates the map view my annotation also rotates which is for obvious reason and my image moves in wrong direction.In android we can set flat property to true so whenever user will rotate the map the annotation image will also rotate along with it.
Please suggest something useful.Thank you.

ios MapKit have annotation description visible on launch and not on tap

I am using map on my IOS application. I can see the annotation on my map, and when I tap on that there is the description, which I have set. My question is whether I can have this description visible when map first loads and not make the user tap on the annotation to view it?
is that possible?
Thanks.
use an overlay instead of an annotation

Bring ios mapview in zoomed in mode during first load

Hello i am doing an iOS6 in-house iPad app. On my ViewController i have a scroll view. On that at the bottom left i have a map view (20,594,360,347).Mapview location on my scroll view. I have a get location button. Brings the location correctly in zoomed in mode (it shows my office on the map clearly).Works fine. I save the record and open another one and save this record also. So i have 2 records now. Here is my problem. I open my first record and it brings the map in world view. I can see the annotation of where my office is and i zoom in... zoom in and i see my office. It doesnt bring the location directly in zoom in mode. I close this 1st record and open 2nd record it brings in the location in zoomed in mode(can see my office). I open first record now, i get zoomed in mode (i can see my office clearly). So how do i get the map view to show my first record the first time in zoomed in mode?
Summary : Opening a saved record for the first time shows the map in world view as against to zoomed in mode.
- (void)setMap:(CLLocationCoordinate2D)currentCoordinates{
....code
[self.nwMapView setMapType:MKMapTypeSatellite];
[self.nwMapView setScrollEnabled:YES];
MKCoordinateRegion extentsRegion = MKCoordinateRegionMakeWithDistance(currentCoordinates, 80, 80);
extentsRegion.span.longitudeDelta = 0.002f;
extentsRegion.span.latitudeDelta = 0.002f;
[self.nwMapView setRegion:extentsRegion animated:NO];
ITMAnnotation *annotation = [[ITMAnnotation alloc] initWithCoordinate:currentCoordinates addressDictionary:nil];
annotation.title = #"Drag to Move Pin";
annotation.subtitle = [NSString stringWithFormat:#"%f %f", annotation.coordinate.latitude, annotation.coordinate.longitude];
NSLog(#"subtitle change at 314");
[self.nwMapView addAnnotation:annotation];
self.tempMapView = self.nwMapView;
}
What setting should i enable to get the map in zoomed in mode.? If you need more information,please ask. Thanks.
At what point are you calling setMap? If you are doing it before viewDidLoad then you'll be losing all the set up you do to the UI because it hasn't been loaded yet. Once the VC is loaded you can setRegion on the map and do what ever. I suspect you are reusing the VC with the second record so it is calling setRegion on map that is read to be used.

Problems with current location pin

I'm working on an app that shows a couple of places on the map along with the user's current position.
I have two small problems with it:
First off, I want the current location pin to be the default blue circle, but it shows a green pin just like the other locations.
Second problem, whenever I touch the screen, the current location pin drops again. It just can't seem to be steady like the other ones. It's like it's being called whenever I interact with the app.
Make sure you set your mapView delegate to self...that should fix the pin color. Not sure about your other problem
// in the viewDidLoad
[mapView setDelegate:self];
where "mapView" is defined as "IBOutlet MKMapView *mapView;"

Resources