MapControl 是否有任何函数允许第二张地图与第一张地图保持一致?即:Zoom/Location

Is there any functions for MapControl that allows a second map to stay consistent with the first map? IE: Zoom/Location

我想知道 MapControl 是否具有允许使用两个地图保持彼此一致的特定功能。具体来说,我想知道是否有办法使第二张地图的缩放比例和中心位置与第一张地图相同。第一张地图允许更改,第二张地图将随之更改。

目前Uwp还没有提供api直接实现这种效果。建议通过数据绑定来实现。

请注意:由于无法将字符串转换为地理点,因此除非使用数据绑定,否则无法在 XAML 标记中为中心 属性 指定值。

Xaml代码:

 <StackPanel >
        <Maps:MapControl  x:Name="MapControl1"
                          Center="{x:Bind CityCenter,Mode=TwoWay}"
                          ZoomLevel="{x:Bind ZoomLevel ,Mode=TwoWay}"
                          Height="300"
                          Width="500"                          
                          ZoomInteractionMode="GestureAndControl"
                          TiltInteractionMode="GestureAndControl"        
                          MapServiceToken="..">
        </Maps:MapControl>
        
        <Maps:MapControl  x:Name="MapControl2"  Height="300"
                          Width="500"                   
                          Center="{x:Bind CityCenter,Mode=OneWay}"                         
                          ZoomLevel="{x:Bind ZoomLevel ,Mode=OneWay}"
                          ZoomInteractionMode="GestureAndControl"
                          TiltInteractionMode="GestureAndControl"        
                          MapServiceToken=".."/>
    </StackPanel>

后面的代码:

public sealed partial class MainPage : Page,INotifyPropertyChanged
{
    private Geopoint cityCenter;
    private double zoomLevel;
    public Geopoint CityCenter
    {
        get { return cityCenter; }
        set { cityCenter = value;
            RaisePropertyChanged("CityCenter");
        }
    }
    public double ZoomLevel{
        get { return zoomLevel; }
        set
        {
            zoomLevel = value;
            RaisePropertyChanged("ZoomLevel");
        }
    }
    public MainPage()
    {
        this.InitializeComponent();
    }

    public event PropertyChangedEventHandler PropertyChanged;
    public void RaisePropertyChanged(string propertyname=null)
    {
        PropertyChanged?.Invoke(this,new PropertyChangedEventArgs(propertyname));
    }
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        // Specify a known location.
        BasicGeoposition cityPosition = new BasicGeoposition() { Latitude = 47.604, Longitude = -122.329 };
        CityCenter = new Geopoint(cityPosition);
        ZoomLevel = 12;      
        MapControl1.LandmarksVisible = true;
    }

}