2017-07-18 187 views

回答

1

如果你想要像Google Earth那樣的東西,你可能需要創建自己的實現。您可以在Xamarin Forms中執行的操作是使用現有的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

對於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 \ tilted街景的級別。 – jaczjill

相關問題