private async void AddLayerContainIcons(object sender, RoutedEventArgs e) { var layer = new AMapLayer(); RandomAccessStreamReference rsa = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/man.png", UriKind.RelativeOrAbsolute)); for (int i = 0; i < 1000; i++) { var icon = new AMapIcon { //Image = // RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/man.png", // UriKind.RelativeOrAbsolute)), Image = rsa, Location = new LngLat(116.394653 + i * 0.01, 39.911843 + i * 0.01), }; await layer.Add(icon); } aMapControl.Layers.Add(layer); }
private void MapTypeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { ComboBox box = sender as ComboBox; MapType map = box.SelectedItem as MapType; switch (map.ID) { case "baidu": myMap.OperationalLayers.Clear(); BaiduMapLayer baiduMap = new BaiduMapLayer(); baiduMap.Id = "MapLayer"; myMap.OperationalLayers.Add(baiduMap); break; case "tencent": myMap.OperationalLayers.Clear(); TencentMapLayer tencentMap = new TencentMapLayer(); myMap.OperationalLayers.Add(tencentMap); tencentMap.Id = "MapLayer"; break; case "amap": myMap.OperationalLayers.Clear(); AMapLayer aMap = new AMapLayer(); myMap.OperationalLayers.Add(aMap); aMap.Id = "MapLayer"; break; default: break; } }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { var layer1 = new AMapLayer(); var layer2 = new AMapLayer(); var layer3 = new AMapLayer(); double interval = 0.1; var icon1 = new AMapIcon { Image = RandomAccessStreamReference.CreateFromUri(new Uri( "ms-appx:///Assets/YELLOW.png", UriKind.RelativeOrAbsolute)), Location = aMapControl.Center, Data = "1" }; icon1.Tapped += icon1_Tapped; var icon2 = new AMapIcon { Image = RandomAccessStreamReference.CreateFromUri(new Uri( "ms-appx:///Assets/CYAN.png", UriKind.RelativeOrAbsolute)), Location = new LngLat(icon1.Location.Longitude + interval, icon1.Location.Latitude + interval), Data = "2" }; icon2.Tapped += icon2_Tapped; var icon3 = new AMapIcon { Image = RandomAccessStreamReference.CreateFromUri(new Uri( "ms-appx:///Assets/GREEN.png", UriKind.RelativeOrAbsolute)), Location = new LngLat(icon2.Location.Longitude + interval, icon2.Location.Latitude + interval), Data = "3" }; icon3.Tapped += icon3_Tapped; layer1.Add(icon1); layer2.Add(icon2); layer3.Add(icon3); aMapControl.Layers.Add(layer1); aMapControl.Layers.Add(layer2); aMapControl.Layers.Add(layer3); aMapControl.MapHolding += aMapControl_Holding; }
/// <summary> /// Add the given map layer to this map control. /// </summary> /// <param name="Layer">A map layer.</param> /// <param name="Visibility">The map layer is visible or not at the start of the application.</param> /// <param name="AddToLayerPanel">Wether to add this map layer to the layer panel or not.</param> public AMapLayer AddLayer(AMapLayer Layer, Visibility Visibility = Visibility.Visible, Boolean AddToLayerPanel = true) { #region Initial checks if (Layer == null) { throw new ApplicationException("The parameter 'Layer' must not be null!"); } var CurrentLayerAsCanvas = Layer as Canvas; if (CurrentLayerAsCanvas == null) { throw new ApplicationException("The parameter 'Layer' must inherit from Canvas!"); } if (Layer.Id == null) { throw new ApplicationException("The identification of the 'Layer' must be set!"); } if (Layer.MapControl != this) { throw new ApplicationException("The MapControl of the 'Layer' is invalid!"); } #endregion #region Add the given feature layer LayerGrid.Children.Add(CurrentLayerAsCanvas); MapLayers.Add(Layer.Id, Layer); CurrentLayerAsCanvas.SetValue(Canvas.ZIndexProperty, Layer.ZIndex); #endregion #region Add a checkbox entry to the feature layer panel if (AddToLayerPanel) { LayerPanel1.AddLayer(Layer, Visibility); } #endregion return(Layer); }
/// <summary> /// 在不同的层上加入不同的marker /// 来测试层的功能是否实现 /// </summary> private async void AddMarkersAtDifferentLayer() { var layer1 = new AMapLayer(); var layer2 = new AMapLayer(); var layer3 = new AMapLayer(); double interval = 0.1; var icon1 = new AMapIcon { Image = RandomAccessStreamReference.CreateFromUri(new Uri( "ms-appx:///Assets/YELLOW.png", UriKind.RelativeOrAbsolute)), Location = aMapControl.Center, Data = "1" }; var icon2 = new AMapIcon { Image = RandomAccessStreamReference.CreateFromUri(new Uri( "ms-appx:///Assets/CYAN.png", UriKind.RelativeOrAbsolute)), Location = new LngLat(icon1.Location.Longitude + interval, icon1.Location.Latitude + interval), Data = "2" }; var icon3 = new AMapIcon { Image = RandomAccessStreamReference.CreateFromUri(new Uri( "ms-appx:///Assets/GREEN.png", UriKind.RelativeOrAbsolute)), Location = new LngLat(icon2.Location.Longitude + interval, icon2.Location.Latitude + interval), Data = "3" }; layer1.Add(icon1); layer2.Add(icon2); layer3.Add(icon3); aMapControl.Layers.Add(layer1); aMapControl.Layers.Add(layer2); aMapControl.Layers.Add(layer3); }
/// <summary> /// Checks if the given map is present within the map control. /// </summary> /// <param name="MapLayer">A map layer.</param> public Boolean ContainsLayerId(AMapLayer MapLayer) { return(MapLayers.ContainsKey(MapLayer.Id)); }
/// <summary> /// Add the given map layer to this expandable stack panel. /// </summary> /// <param name="Layer">A map layer.</param> /// <param name="Visibility">The map layer is visible or not at the start of the application.</param> public void AddLayer(AMapLayer Layer, Visibility Visibility = Visibility.Visible) { #region Initial checks if (Layer == null) throw new ApplicationException("The parameter 'Layer' must not be null!"); var CurrentLayerAsCanvas = Layer as Canvas; if (CurrentLayerAsCanvas == null) throw new ApplicationException("The parameter 'Layer' must inherit from Canvas!"); if (Layer.Id == null) throw new ApplicationException("The identification of the 'Layer' must be set!"); if (Layer.MapControl == null) throw new ApplicationException("The MapControl of the 'Layer' must be set!"); #endregion var Checkbox = new CheckBox(); Checkbox.Content = Layer.Id; Checkbox.IsChecked = Visibility == Visibility.Visible; Layer.Visibility = Visibility; #region Register Checkbox.MouseEnter event Checkbox.MouseEnter += (o, e) => { var _CheckBox = o as CheckBox; _CheckBox.Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)); _CheckBox.Background = new SolidColorBrush(Colors.White); }; #endregion #region Register Checkbox.MouseLeave event Checkbox.MouseLeave += (o, e) => { var _CheckBox = o as CheckBox; _CheckBox.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); _CheckBox.Background = new SolidColorBrush(Colors.Gray); }; #endregion #region Register Checkbox.Click event Checkbox.Click += (o, e) => { var _CheckBox = o as CheckBox; if (_CheckBox.IsChecked.Value) CurrentLayerAsCanvas.Animate(Property: "Opacity", From: 0.0, To: 1.0, Milliseconds: AnimationSpeed, StartAction: (UIElement) => { Layer.Redraw(); UIElement.Visibility = Visibility.Visible; }); else CurrentLayerAsCanvas.Animate(Property: "Opacity", From: 1.0, To: 0.0, Milliseconds: AnimationSpeed, FinalAction: (UIElement) => UIElement.Visibility = Visibility.Hidden); }; #endregion base.AddUIElement(Checkbox); }
/// <summary> /// Add the given map layer to this expandable stack panel. /// </summary> /// <param name="Layer">A map layer.</param> /// <param name="Visibility">The map layer is visible or not at the start of the application.</param> public void AddLayer(AMapLayer Layer, Visibility Visibility = Visibility.Visible) { #region Initial checks if (Layer == null) { throw new ApplicationException("The parameter 'Layer' must not be null!"); } var CurrentLayerAsCanvas = Layer as Canvas; if (CurrentLayerAsCanvas == null) { throw new ApplicationException("The parameter 'Layer' must inherit from Canvas!"); } if (Layer.Id == null) { throw new ApplicationException("The identification of the 'Layer' must be set!"); } if (Layer.MapControl == null) { throw new ApplicationException("The MapControl of the 'Layer' must be set!"); } #endregion var Checkbox = new CheckBox(); Checkbox.Content = Layer.Id; Checkbox.IsChecked = Visibility == Visibility.Visible; Layer.Visibility = Visibility; #region Register Checkbox.MouseEnter event Checkbox.MouseEnter += (o, e) => { var _CheckBox = o as CheckBox; _CheckBox.Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)); _CheckBox.Background = new SolidColorBrush(Colors.White); }; #endregion #region Register Checkbox.MouseLeave event Checkbox.MouseLeave += (o, e) => { var _CheckBox = o as CheckBox; _CheckBox.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); _CheckBox.Background = new SolidColorBrush(Colors.Gray); }; #endregion #region Register Checkbox.Click event Checkbox.Click += (o, e) => { var _CheckBox = o as CheckBox; if (_CheckBox.IsChecked.Value) { CurrentLayerAsCanvas.Animate(Property: "Opacity", From: 0.0, To: 1.0, Milliseconds: AnimationSpeed, StartAction: (UIElement) => { Layer.Redraw(); UIElement.Visibility = Visibility.Visible; }); } else { CurrentLayerAsCanvas.Animate(Property: "Opacity", From: 1.0, To: 0.0, Milliseconds: AnimationSpeed, FinalAction: (UIElement) => UIElement.Visibility = Visibility.Hidden); } }; #endregion base.AddUIElement(Checkbox); }