private void SbAddClick(object sender, RoutedEventArgs e) { var l = ((FrameworkElement) sender).DataContext as StoredLayer; if (l == null) return; switch (l.Type) { case "Map Service": var ml = new ArcGISImageServiceLayer(); ml.Url = l.Id; ml.ID = l.Title; ml.Visible = true; var pts = AppStateSettings.Instance.ViewDef.FindOrCreateAcceleratedGroupLayer(l.Path); pts.ChildLayers.Add(ml); ml.Initialize(); break; // FIXME TODO: Unreachable code //break; case "Feature Service": var fl = new FeatureLayer() {}; fl.Url = l.Id + @"/0"; fl.ID = l.Title; fl.Visible = true; fl.InitializationFailed += fl_InitializationFailed; fl.Initialized += fl_Initialized; fl.UpdateCompleted += fl_UpdateCompleted; var pt = AppStateSettings.Instance.ViewDef.FindOrCreateAcceleratedGroupLayer(l.Path); pt.ChildLayers.Add(fl); fl.Initialize(); fl.Update(); break; case "wms": var wl = new WmsLayer { SupportedSpatialReferenceIDs = new[] {102100}, Visible = false }; wl.Visible = true; wl.SkipGetCapabilities = false; wl.Initialized += (st, es) => { wl.Layers = wl.LayerList.Select(k => k.Title).ToArray(); }; wl.Url = l.Id; wl.ID = l.Title; wl.Title = l.Title; var p = AppStateSettings.Instance.ViewDef.FindOrCreateGroupLayer(l.Path); p.ChildLayers.Add(wl); wl.Initialize(); break; } AppStateSettings.Instance.ViewDef.StoredLayers.Add(l); AppStateSettings.Instance.ViewDef.StoredLayers.Save(); }
public void Add() { //WmtsLayer kml = new WmtsLayer() // { // ID = Name, // Url = // "http://134.221.210.43:8008/geoserver/gwc/service/wmts?REQUEST=getcapabilities" // }; kml = new WmsLayer() { ID = Name, Url = Location }; gl = AppState.ViewDef.FindOrCreateGroupLayer(this.Folder); //kml.Version = "1.1.0"; //kml.ServiceMode = WmtsLayer.WmtsServiceMode.KVP; kml.Layers = Layers; if (gl != null) gl.ChildLayers.Add(kml); kml.Initialize(); IsRunning = true; }