MKMapKit inset - how can I show the United States on a large map and Alaska and Hawaii on two smaller MKMapKit maps

Hi,


I am trying to show the 48 states on a large central map for an iPad (working fine) but I want to show Alask and Hawaii on two smaller MKMapKits on smaller inset windows.


I have Alaska working but the zoom level is too close ... and when I try to zoom out, it does not zoom.


Are there examples of multiple maps of varying sizes for this type of problem ?


Thanks !

Answered by pkasson in 100521022

No, wanted to see if I was missing something. Thanks for your help.

If you provide an example of how you are setting the map region which you are not able to get working, then perhaps someone can see what is wrong with the code.

Yep, that would have been the way to go ... sorry, was rushing out the door this morning.


Primary:


CLLocationCoordinate2D coordinates[6];
coordinates[0] = CLLocationCoordinate2DMake(84.440107, 122.34375);
coordinates[1] = CLLocationCoordinate2DMake(-77.841848, -178.769531);
coordinates[2] = CLLocationCoordinate2DMake(-58.077876, -103.007812);
coordinates[3] = CLLocationCoordinate2DMake(-53.956086, 68.554688);
coordinates[4] = CLLocationCoordinate2DMake(76.351896, 41.132813);
coordinates[5] = CLLocationCoordinate2DMake(76.184995, -172.617187);
MKPolygon *polygon = [MKPolygon polygonWithCoordinates:coordinates count:6];
polygon.title = @"background";
[self.mapView addOverlay:polygon];
Alaska:
[self.mapViewAlaska addOverlay:polygon];


Alaska is resized to about 1/10th the main map view and is z-order above the primary.


Thanks.

That section of code does not show how you set the map region for your insets. Setting an overlay does not change the displayed map region.


This would be done with a calling setVisibleMapRect:edgePadding:animated, for example.


(Pro tip: you can use the "<>" brackets on the toolbar to surround code for better formatting in the forums.)

Right ... here is that code:


CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(61.3008186, -158.7750198);

MKCoordinateRegion region;

region.center.latitude     = coord.latitude;
region.center.longitude    = coord.longitude;
region.span.latitudeDelta  = 24;                   
region.span.longitudeDelta = 24;

region = [mapViewAlaska regionThatFits:region];

[mapViewAlaska setRegion:region animated:FALSE];

Tweak your latitude, longitude, and span deltas to get the frame you want for the inset map views. Should be pretty easy to iterate through and refine using the simulator.


Not seeing a programming problem I can help with here. When posting originally, were you looking for someone to do this for you and post the values?

Accepted Answer

No, wanted to see if I was missing something. Thanks for your help.

MKMapKit inset - how can I show the United States on a large map and Alaska and Hawaii on two smaller MKMapKit maps
 
 
Q