MKCoordinateRegion adjustedRegion = [mapView regionThatFits:MKCoordinateRegionMakeWithDistance(userLocation, 800, 800)];
// Calculate the offset to scroll up the map. This example is just a rough guess.
// You should use your concrete UI item's geometry for a more accurate calcluation.
CLLocationDegrees moveUpDistance = adjustedRegion.span.latitudeDelta / 3 * 2;
// Move the centerfurther down to scroll up the map.
adjustedRegion.center.latiude = adjustedRegion.center.latitude + moveUpDistance;
[mapView setRegion:adjustedRegion animated:animated];
MKMapkit Center the userLocation annotation in another other views coordinates
-
19-06-2023 - |
Pergunta
I have an MKMapView behind another view with a transparent portion for viewing.
How can I center the userlocation in mapview in the viewing window on the top view?
See images below for a visual...
This image show the two layers and how they are composed.
This image shows the the full picture. You can see the user location beacon pulsing just below the viewing window.
I have tried creating a region that fits the userLocation annotation and manually adjusting the regions span deltas to various arbitrary values but that did not do the trick.
MKCoordinateRegion adjustedRegion = [mapView regionThatFits:MKCoordinateRegionMakeWithDistance(userLocation, 800, 800)];
adjustedRegion.span.longitudeDelta = 0.005;
adjustedRegion.span.latitudeDelta = 0.005;
[mapView setRegion:adjustedRegion animated:animated];
Any ideas??
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow