1
NTVectorElements의 배열이 있는데, 모든 요소를 화면에 맞출 수 있도록 맵 경계를 어떻게 설정합니까? 내가 moveToFitBounds 함수를 볼 수 있지만 그것을 구현하는 방법을 잘 모르겠습니다. 모범이 있습니까?Carto 모바일 SDK의 객체에 맵핑
NTVectorElements의 배열이 있는데, 모든 요소를 화면에 맞출 수 있도록 맵 경계를 어떻게 설정합니까? 내가 moveToFitBounds 함수를 볼 수 있지만 그것을 구현하는 방법을 잘 모르겠습니다. 모범이 있습니까?Carto 모바일 SDK의 객체에 맵핑
이전에이 문제를 다뤘습니다. 그것을 알아내는 것은 쉬운 일이 아니지만이 문제를 해결하는 예제 스 니펫을 제공 할 수 있습니다.
바운드 상자를 그리는 데 필요한 최소 및 최대 위치를 나타내는 화면 경계와지도 경계를 제공해야합니다. 즉시 객체의 경계를 얻을 수있는 방법이없는
NTVectorElements, 당신은 여기에
가지도에 맞게 코드 조각의 자신의 형상의 세계 최대와 최소를 찾기 위해 배열의 모든 요소를 통해 갈 필요 것-(void)fitMapToCurrentlyLoadedSites {
int siteCount = (int)[_sitesOrderArray count];
if (siteCount > 0) {
if (siteCount == 1) {
//zoom in on single site
GenericMapMarker *siteMarker = [_sitesOrderArray objectAtIndex:0];
NTMapPos *sitePosition = [CommonFunctions getMapPosFromCoordinate:_ntMapView coordinate:siteMarker.coordinate];
[_ntMapView setFocusPos:sitePosition durationSeconds:0];
[_ntMapView setZoom:15.0 durationSeconds:0];
} else {
//create vector of multiple sites
NTMapPosVector* posVector = [[NTMapPosVector alloc] init];
for (int i = 0; i < siteCount; i++) {
GenericMapMarker *siteMarker = [_sitesOrderArray objectAtIndex:i];
//get mapPos from coordinate
NTMapPos *mapPos = [CommonFunctions getMapPosFromCoordinate:_ntMapView coordinate:siteMarker.coordinate];
[posVector add:mapPos];
}
//create envelope of vectors
NTMapEnvelope *envelope = [[NTMapEnvelope alloc] initWithConvexHull:posVector];
//get mapBounds of envelope
NTMapBounds *bounds = [envelope getBounds];
[_ntMapView moveToFitBounds:bounds screenBounds:[self findScreenBounds] integerZoom:TRUE durationSeconds:1.0f];
}
}
}
그리고 화면 경계를 확인하는 방법은 다음과 같습니다 :
-(NTScreenBounds *)findScreenBounds {
float screenWidth = self.view.frame.size.width;
float screenHeight = self.view.frame.size.height;
NTScreenPos *minScreenPos = [[NTScreenPos alloc] initWithX:0.0 y:0.0];
NTScreenPos *maxScreenPos = [[NTScreenPos alloc] initWithX:screenWidth y:screenHeight];
return [[NTScreenBounds alloc] initWithMin:minScreenPos max:maxScreenPos];
}
을 현재로드 사이트는, 당신은 당신의 사용 사례에 맞게 그것에 약간의 수정 만 필요로한다