/// <summary> /// Create an instance of the DeepEarth Map Control /// </summary> public Map() { DefaultInstance = this; _SpatialReference = new MercatorProjection(); _TileLayer = new TileLayer(this); _MouseControl = new MouseControl(this); _Layers = new ObservableCollection<ILayer>(); _Layers.CollectionChanged += Layers_CollectionChanged; DefaultStyleKey = typeof (Map); DisplayUnit = Unit.Meter; DragMode = DragBehavior.Pan; //Wire up the keyboard events. TabNavigation = KeyboardNavigationMode.Once; IsTabStop = true; KeyDown += (o, e) => Events.KeyDown(this, e); KeyUp += (o, e) => Events.KeyUp(this, e); //Create event handlers for default map behavior Events.MapDoubleClick += MapDoubleClick; Events.MapZoomEnded += (o, e) => _TargetZoom = 0; Events.MapLoaded += (o, e) => UpdateCenterPoint(); Events.MapTileSourceChanged += (o, e) => UpdateCopyrights(); }
/// <summary> /// Overrides the default OnApplyTemplate to configure child FrameworkElement references from the applied template /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); //Get instances from the template _MapContent = (Grid) GetTemplateChild(PART_MapContent); _MapLayerGrid = (Grid) GetTemplateChild(PART_MapLayers); _MapRotation = (RotateTransform) GetTemplateChild(PART_MapRotation); _LicenseContainer = (Panel)GetTemplateChild(PART_LicenseContainer); _MouseControl = (MouseControl) GetTemplateChild(PART_MouseControl); _MouseControl.MapInstance = this; _MapContent.Children.Insert(0, _TileLayer); //Perform any necessary intialization to the elements RotationAngle = _MapRotation.Angle; ConfigMapLayers(); ConfigMapRotation(); LayoutUpdated += (o, e) => UpdateClippingArea(); }