2017-02-20 136 views
1

需要移動到當前位置Esri地圖當用戶單擊當前位置按鈕時。我試圖找出,但無法找到任何關於它的ESRI的地圖在Esri地圖中點擊位置按鈕時移動到當前位置

我下面的代碼,但它不工作

//MARK: 
    //MARK: current location button clicked 
    func btnCurLoc_Clicked(_ sender:UIButton) 
    { 
     arcGISMapView.locationDisplay.startDataSource() 
    } 

回答

1

如果你想在地圖自動縮放到當前位置您還需要將位置顯示 上的autopan mode設置爲其中一個選項here 最基本的居中之一是AGSLocationDisplayAutoPanModeRecenter。

0

swift 4和Esri ios SDK 100.1示例;

func locationOpen(){ 
    self.mapView.locationDisplay.start { _ in 
     let x:Double = (self.mapView.locationDisplay.mapLocation?.x)! 
     let y:Double = (self.mapView.locationDisplay.mapLocation?.y)! 
     DispatchQueue.main.async { 
      if (self.mapView.locationDisplay.started == false) 
      { 
       // permission location 

      } 
      else 
      { // zoom to geometry 
       self.mapView.setViewpointCenter(AGSPoint(x: x, y: y, spatialReference: AGSSpatialReference.webMercator()), scale: self.mapView.mapScale, completion: nil) 
      } 
     } 

    } 


} 
相關問題