MKMapView에 삼각형 폴리곤이있어서 매우 빠르게 다시 그리거나 전화의 특정 위치에 고정하려고합니다.iOS MKMapView가지도에 오버레이를 재빨리 다시 그립니다.
이 다각형은 항상 휴대 전화의 상단을 가리키지 만지도 자체는 제공된 제목으로 회전합니다. 현재 내가 가진 유일한 방법은 오버레이를 제거한 다음 다시 추가하는 것입니다. 이 문제는 매우 고르지입니다.
다음 아이디어는 맵 위에 삼각형 이미지를 추가하고 필요에 따라 맵의 크기를 조정하는 것이 었습니다.이 삼각형 이미지는 맵 오버레이로 추가 될 때 폴리곤이 무엇인지를 정확하게 시각화 한 것입니다. 이 은 거의이지만 작동은 정확하지 않습니다. 어떤 이유로 위도 줌 레벨의 변경 사항 및 기타 문제에 거의 응답하지 않습니다. 이것에 대한
내 방법은 다음과 같습니다에 관계없이 항상지도 회전 화면 상단을 가리키는 오버레이를 유지하는 방법은
- (void)setMapVisibleRect {
//we have to mock the heading to 0 so that the distances show up in lat/long correctly
//create a new instance of the cone model with a fake heading of 0 for calculations
ConePolygonModel *conePolygonModel = [[ConePolygonModel alloc] init:[self.userLocationModel getLocation].coordinate
withHeading:0
withLatLongMultiplier:[self.conePolygonModel getLatLongMultiplier]
withDistanceMultiplier:[self.conePolygonModel getDistanceMultiplier]];
//reset the map heading to 0
[self.mapView.camera setHeading:0];
//top left setup
CLLocationCoordinate2D topLeftCoordinate;
topLeftCoordinate.latitude = [[[conePolygonModel getXCoordinates] objectAtIndex:1] doubleValue];
topLeftCoordinate.longitude = [[[conePolygonModel getYCoordinates] objectAtIndex:1] doubleValue];
CLLocation *topLeftLocation = [[CLLocation alloc] initWithLatitude:topLeftCoordinate.latitude longitude:topLeftCoordinate.longitude];
//top right setup
CLLocationCoordinate2D topRightCoordinate;
topRightCoordinate.latitude = [[[conePolygonModel getXCoordinates] objectAtIndex:2] doubleValue];
topRightCoordinate.longitude = [[[conePolygonModel getYCoordinates] objectAtIndex:2] doubleValue];
CLLocation *topRightLocation = [[CLLocation alloc] initWithLatitude:topRightCoordinate.latitude longitude:topRightCoordinate.longitude];
//center setup
CLLocationCoordinate2D topCenterCoordinate = [conePolygonModel midpointBetweenCoordinate:topLeftCoordinate andCoordinate:topRightCoordinate];
CLLocation *topCenterLocation = [[CLLocation alloc] initWithLatitude:topCenterCoordinate.latitude longitude:topCenterCoordinate.longitude];
//set distances
CLLocationDistance latitudeDistance = [topLeftLocation distanceFromLocation:topRightLocation];
CLLocationDistance longitudeDistance = [topCenterLocation distanceFromLocation:[self.userLocationModel getLocation]];
//set the map zoom
NSLog(@"zoom levels: %f %f", latitudeDistance, longitudeDistance);
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance([self.userLocationModel getLocation].coordinate, latitudeDistance, longitudeDistance);
[self.mapView setRegion:viewRegion];
//move the map to the actual heading
[self.mapView.camera setHeading:self.currentHeading];
}
있습니까? 오버레이가 화면에서 항상 같은 크기를 차지하도록지도를 확대하는 것도 좋지만 다른 지점만큼 중요하지는 않습니다.
두 번 확인하려면 사용자가지도를 조작하는 방법에 관계없이 삼각형이 항상 사용자 화면에서 동일한 물리적 크기를 유지하고 동일한 회전을 유지하게해야합니까? –