Question

I am new to xcode, and am trying to create an annotation. The annotation works fine, its just that when the app opens the map is focused on europe! Should I change the coordinates to my latitude and longitude of my annotation location, and how do I do that? Beczuse there are four 0's instead of two! {{0,0},{0,0}} how do i configure latitude and longutude into that?

Was it helpful?

Solution

A MKCoordinateRegion has two fields: 1) center, 2) span.

You should use the MKCoordinateRegionMake macro for this:

CLLocationCoordinate2D center = CLLocationCoordinate2DMake(35, -90); // pick desired values
MKCoordinateSpan span = MKCoordinateSpanMake(100, 100); // pick desired values
MKCoordinateRegion region = MKCoordinateRegionMake(center, span);

The syntax:

MKCoordinateRegion region = { { 0, 0 }, { 0, 0 } };

is a shortcut from C for initializing the struct values. The first pair is for the center field and the second pair is for the span field.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top