protected void OnMapMapLayerError(MapErrorEventArgs e) { if (MapLayerError != null) { MapLayerError(this, e); } }
private static void MapLayerPropertyChanged(object sender, DependencyPropertyChangedEventArgs e) { if (e.NewValue != null) { MapControl map = (MapControl)sender; SuperMapProvider provider = null; try { if (e.NewValue is MapByScalesLayer) { MapByScalesLayer temp = e.NewValue as MapByScalesLayer; provider = new SuperMapProvider(temp.ServiceUrl, temp.MapName, temp.Scales); } else if (e.NewValue is MapByZoomCountLayer) { MapByZoomCountLayer temp = e.NewValue as MapByZoomCountLayer; provider = new SuperMapProvider(temp.ServiceUrl, temp.MapName, temp.ZoomCount, temp.DefaultScaleIndex); } } catch (Exception ex) { MapErrorEventArgs mapEx = new MapErrorEventArgs("初始化地图图层时发生异常", ex); map.OnMapMapLayerError(mapEx); return; } map._bounds = new Rectangle2D( provider.Projection.Bounds.Left, provider.Projection.Bounds.Bottom, provider.Projection.Bounds.Right, provider.Projection.Bounds.Top); map.gMapControl1.MapProvider = provider; map.gMapControl1.MaxZoom = provider.MapScales.Length - 1; map.gMapControl1.MinZoom = 0; map.gMapControl1.Zoom = 0; map.Center = provider.DefaultMapCenter; map._scales = provider.MapScales; map.OnPropertyChanged(e); } }
void Map_MapLayerError(object sender, MapErrorEventArgs e) { _sync.Post(ShowMessage, "地图图层异常"); }