private void InitDataConnection(CIMKMLDataConnection connection) { WorkspacePath = connection.KMLURI; DataSourceName = Path.GetFileName(WorkspacePath); DataSetName = DataSourceName; DataSetType = "KML File/Service"; DataSource = connection.KMLURI; }
public void gsAddLayer(String serviceType, String serviceUrl, String referenceId, Object callback) { String url = serviceUrl; bool ok = false; dynamic callbackFunc = callback; if (serviceType != null && MapView.Active != null && MapView.Active.Map != null) { //serviceType = "Feature Service"; url = @"http://sampleserver6.arcgisonline.com/arcgis/rest/services/NapervilleShelters/FeatureServer"; //serviceType = "Feature Service"; url = @"http://sampleserver6.arcgisonline.com/arcgis/rest/services/NapervilleShelters/FeatureServer/0"; //serviceType = "Map Service"; url = @"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"; //serviceType = "Map Service"; url = @"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"; //serviceType = "Image Service"; url = @"http://sampleserver6.arcgisonline.com/arcgis/rest/services/Toronto/ImageServer"; //serviceType = "WMS"; url = @"http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0q.cgi"; //serviceType = "KML"; url = @"http://www.ndbc.noaa.gov/kml/marineobs_as_kml.php"; Map map = MapView.Active.Map; QueuedTask.Run(() => { try { if (serviceType == "WMS") { var serverConnection = new CIMInternetServerConnection { URL = url }; var connection = new CIMWMSServiceConnection { ServerConnection = serverConnection }; LayerFactory.Instance.CreateLayer(connection, map); ok = true; } else if (serviceType == "KML") { var connection = new CIMKMLDataConnection { KMLURI = url }; LayerFactory.Instance.CreateLayer(connection, map); ok = true; } else { Layer lyr = LayerFactory.Instance.CreateLayer(new Uri(url), map); ok = true; } } catch (Exception e) { Console.WriteLine("Error adding layer {0}", e); } callbackFunc(ok); }); } else { callbackFunc(ok); } }
public void gsAddLayer(string serviceType, string serviceUrl, string referenceId, object callback) { string url = serviceUrl; string type = serviceType; bool ok = false; dynamic callbackFunc = callback; QueuedTask.Run(() => { if (MapView.Active == null) { MessageBox.Show("Please open a map before adding items.", "No Map Open", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); callbackFunc(ok); return; } if (serviceType != null) { //serviceType = "Feature Service"; url = @"http://sampleserver6.arcgisonline.com/arcgis/rest/services/NapervilleShelters/FeatureServer"; //serviceType = "Feature Service"; url = @"http://sampleserver6.arcgisonline.com/arcgis/rest/services/NapervilleShelters/FeatureServer/0"; //serviceType = "Map Service"; url = @"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"; //serviceType = "Map Service"; url = @"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"; //serviceType = "Image Service"; url = @"http://sampleserver6.arcgisonline.com/arcgis/rest/services/Toronto/ImageServer"; //serviceType = "WMS"; url = @"http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0q.cgi"; //serviceType = "KML"; url = @"http://www.ndbc.noaa.gov/kml/marineobs_as_kml.php"; var map = MapView.Active?.Map; try { if (serviceType == "WMS") { var serverConnection = new CIMInternetServerConnection { URL = url }; var connection = new CIMWMSServiceConnection { ServerConnection = serverConnection }; var item = ItemFactory.Instance.Create(url, ItemFactory.ItemType.PortalItem); if (LayerFactory.Instance.CanCreateLayerFrom(item)) { LayerFactory.Instance.CreateLayer(item, map); } //LayerFactory.Instance.CreateLayer(connection, map); ok = true; } else if (serviceType == "KML") { var connection = new CIMKMLDataConnection { KMLURI = url }; LayerFactory.Instance.CreateLayer(connection, map); ok = true; } else { Layer lyr = LayerFactory.Instance.CreateLayer(new Uri(url), map); ok = true; } } catch (Exception e) { Console.WriteLine("Error adding layer {0}", e); } callbackFunc(ok); } else { callbackFunc(ok); } }); }
private static string GetKMLDataPathName(CIMKMLDataConnection dataConnection) { return(dataConnection?.KMLURI); // e.g "D:\Temp\KML_Samples.kml". }