2017-07-18 6 views
0

Xamarin.Formsを使用して、Android、iOS & Windows.UWPの地球の3Dマップで選択した都市を表示する必要があります。現在、Xamarin.Forms.Mapsを使用していますが、地球の2Dマップのみを表示しています。Xamarn.formsの地図の地球儀(3Dビュー)を表示するには

地球の3Dマップはどうやって行くのですか?

注:マップのズームイン機能も必要です。

答えて

1

Google Earthのようなものが必要な場合は、おそらく独自の実装を作成する必要があります。ただし、Xamarinフォームでできることは、既存のXamarin.Forms.Mapsコントロールを使用して、カメラと呼ばれるものを追加することです。基本的に、これはあなたが地図を見る視点です。これらは3D空間にあるので、3Dマップを持っているように見えます。カスタムレンダラーを使用してこれを作成できます。

これらのカスタムレンダラー内では、ピッチ、見出し、および距離などの項目が表示されます。私は準備ができてカスタムレンダラを持っていないが、あなたはできるはずです

enter image description here

のiOSカスタムレンダラ

[assembly: ExportRenderer(typeof(Map3d), typeof(MapView3dRenderer))] 
namespace MyApp.iOS.Renderers 
{ 
    public class MapView3dRenderer : MapRenderer 
    { 
     MKMapView _nativeMap; 

     protected override void OnElementChanged(ElementChangedEventArgs<View> e) 
     { 
      base.OnElementChanged(e); 

      if (e.NewElement != null && Control != null) 
      { 
       _nativeMap = Control as MKMapView; 
      } 
     } 

     protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) 
     { 
      base.OnElementPropertyChanged(sender, e); 

      if (_nativeMap == null) 
       return; 

      if (e.PropertyName == "VisibleRegion") 
       UpdateCameraView(); 
     } 

     void UpdateCameraView() 
     { 
      var target = new CLLocationCoordinate2D(50.890119f, 5.857798f); 

      //Enable 3D buildings 
      _nativeMap.ShowsBuildings = true; 
      _nativeMap.PitchEnabled = true; 

      // Attach the camera 
      var camera = MKMapCamera.CameraLookingAtCenterCoordinate(target, 650, 60, 0); 
      _nativeMap.Camera = camera; 
     } 
    } 
} 

アンドロイド

Android用:このイメージのショーは、どのようなものですを解決する。また、Cameraオブジェクトを添付します。今回は、それをGoogleMapのインスタンスに追加します。

// Create the camera 
CameraPosition cameraPosition = new CameraPosition.Builder() 
                .Target(location) 
                .Tilt(45) 
                .Zoom(10) 
                .Bearing(0) 
                .Build(); 
// Convert to an update object 
CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); 

// Attach the camera 
map.MoveCamera(cameraUpdate); // map is of type GoogleMap 

この方法についてはAndroid docsをご覧ください。

+0

答えていただきありがとうございます。しかし、地球の球面図(地球)上の特定の都市のピンを表示する必要があります。私たちは、3D \斜めの通りを見ることができるレベルにズームインする必要はありません。 – jaczjill

関連する問題