2017-09-28 3 views

答えて

0

私はこれまでにこの問題を扱ってきました。それを理解することは簡単なことではありませんでしたが、私はこの問題を解決するサンプルスニペットを提供することができます。

境界線を描画するために必要な最小値と最大値を指定して、画面境界とマップ境界を指定する必要があります。

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]; 
} 
関連する問題