<UserControl x:Class="MVVM_MapDev.MainPage" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:esri="http://schemas.esri.com/arcgis/client/2009" xmlns:viewModel="clr-namespace:MVVM_MapDev.ViewModel;assembly=MVVM_MapDev.ViewModel" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <Grid x:Name="LayoutRoot" Background="Black"> <Grid.DataContext> <viewModel:MainPageViewModel/> </Grid.DataContext> <ContentPresenter Content="{Binding Path=BaseMap}"/> <esri:Navigation Map="{Binding Path=BaseMap}"/> </Grid> </UserControl>
void SetBaseMap() { try { BaseMap = new Map(); BaseMap.BorderBrush = new SolidColorBrush(Colors.Gray); BaseMap.BorderThickness = new Thickness(1.0); BaseMap.Extent = GetMapExtent(); BaseMap.IsLogoVisible = false; BaseMap.Layers = MapLayers; BaseMap.MinimumResolution = GetMinResolution(); BaseMap.ExtentChanged += new EventHandler<ExtentEventArgs>(BaseMap_ExtentChanged); } catch { throw; } }
<Grid x:Name="LayoutRoot" Background="Black"> <Grid.DataContext> <viewModel:MainMapViewModel/> </Grid.DataContext> <esri:Map x:Name="map_BaseMap" Layers="{Binding Path=MapLayers}" helpers:MapHelper.ZoomGeometry="{Binding Path=MapExtent}"/> <esri:Navigation Margin="5" Map="{Binding ElementName=map_BaseMap}"/> <esri:MapProgressBar Map="{Binding ElementName=map_BaseMap}" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,5" MinWidth="150"/> </Grid>
public static class MapHelper { static readonly DependencyProperty zoomGeometry = DependencyProperty.RegisterAttached("ZoomGeometry", typeof(Geometry), typeof(MapHelper), new PropertyMetadata(new PropertyChangedCallback(OnZoomGeometryChanged))); public static Geometry GetZoomGeometry(DependencyObject d) { return (Geometry)d.GetValue(zoomGeometry); } public static void SetZoomGeometry(DependencyObject d, Geometry value) { d.SetValue(zoomGeometry, value); } private static void OnZoomGeometryChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Map map = d as Map; if (map == null) throw new ArgumentException("DependencyObject must be of type ESRI.ArcGIS.Client.Map"); Geometry newZoomGeometry = GetZoomGeometry(map); if (map.Extent == null) { map.Extent = newZoomGeometry.Extent; map.MaximumResolution = map.Resolution; } else map.ZoomTo(newZoomGeometry); } }
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.