Guest User

Untitled

a guest
Nov 24th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. public class ViewModel : INotifyPropertyChanged
  2. {
  3. private Model myModel = null;
  4. private MapView mapView = null;
  5. public event PropertyChangedEventHandler PropertyChanged;
  6. public ViewModel()
  7. {
  8. var URI = "D:/GIS/Runtime/Tutorial/VanSchools.tpk";
  9. ArcGISLocalTiledLayer localTiledLayer = new ArcGISLocalTiledLayer(URI);
  10. localTiledLayer.ID = "SF Basemap";
  11. localTiledLayer.InitializeAsync();
  12.  
  13. this.mapView.Map.Layers.Add(localTiledLayer);
  14.  
  15. }
  16. public string TilePackage
  17. {
  18. get { return this.myModel.TilePackage; }
  19. set
  20. {
  21. this.myModel.TilePackage = value;
  22.  
  23. }
  24. }
  25.  
  26. public class Model
  27. {
  28. private string tilePackage = "";
  29.  
  30. public Model() { }
  31.  
  32. public string TilePackage
  33. {
  34. get { return this.tilePackage; }
  35. set
  36. {
  37. if (value != this.tilePackage)
  38. {
  39. this.tilePackage = value;
  40. }
  41. }
  42. }
  43.  
  44. <Window x:Class="SimpleMVVM.MainWindow"
  45. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  46. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  47. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  48. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  49. xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
  50. xmlns:local="clr-namespace:SimpleMVVM"
  51. mc:Ignorable="d"
  52. Title="MainWindow" Height="350" Width="525">
  53.  
  54. <Window.Resources>
  55. <local:ViewModel x:Key="VM"/>
  56. </Window.Resources>
  57.  
  58. <Grid DataContext="{StaticResource VM}">
  59. <Grid.RowDefinitions>
  60. <RowDefinition Height="400" />
  61. <RowDefinition Height="200" />
  62. </Grid.RowDefinitions>
  63.  
  64. <esri:MapView x:Name="MyMapView" Grid.Row="0"
  65. LayerLoaded="MyMapView_LayerLoaded" >
  66. <esri:Map> </esri:Map>
  67. </esri:MapView>
  68.  
  69. </Grid>
  70. </Window>
  71.  
  72. public partial class MainWindow : Window
  73. {
  74. public MainWindow()
  75. {
  76. InitializeComponent();
  77. }
  78.  
  79. private void MyMapView_LayerLoaded(object sender, LayerLoadedEventArgs e)
  80. {
  81. if (e.LoadError == null)
  82. return;
  83.  
  84. Debug.WriteLine(string.Format("Error while loading layer : {0} - {1}", e.Layer.ID, e.LoadError.Message));
  85. }
  86.  
  87. }
Add Comment
Please, Sign In to add comment