0
我在視圖控制器中有一個函數,它具有當位置更改時調用的mapkit。我想設置爲地圖視圖,以便以當前位置爲中心並在更新時隨其移動。更新位置時的地圖視圖範圍更改
它在某種意義上說起作用,即它可以跟蹤,但它始終在放大真的很遠。如果我縮小了它對齊回到它在獲取新位置後再次調用更新的位置。
in from params CLLocation *loc
bool first = TRUE;
if(first){
first=FALSE; // bit of a bodge...if i set this to false it will track the update possition but not at the desired "zoom" its look far to close.
CLLocation *loc = [[CLLocation alloc] initWithLatitude:54.976619 longitude:-1.613118];//newcastle city center.
CLLocationDegrees spanLat = 1000;
CLLocationDegrees spanLng = 1000;
userLocation = MKCoordinateRegionMakeWithDistance(loc.coordinate, spanLat, spanLng);
[mapview setRegion:userLocation animated:TRUE];
}else {
CLLocationDegrees spanLat = [mapview region].span.latitudeDelta;// keep the originals? DOESN'T WORK!!
CLLocationDegrees spanLng = [mapview region].span.longitudeDelta;//
userLocation = MKCoordinateRegionMakeWithDistance(loc.coordinate, spanLat, spanLng);
[mapview setRegion:userLocation animated:TRUE];
}
很感謝。我確實在視圖的第一部分關閉了。但似乎沒有工作。在if作品的第二部分設置中心。但我確實需要擺脫,如果這就是爲什麼我說這是一個閃光點。 – Andrew