2017-07-18 183 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

相关问题