예제 #1
0
 private void InitDataConnection(CIMWMSServiceConnection connection)
 {
     WorkspacePath  = connection.ServerConnection.URL;
     DataSourceName = connection.LayerName;
     DataSetName    = DataSourceName;
     DataSetType    = "Web Mapping Service";
     DataSource     = BuildFullUrl();
 }
예제 #2
0
        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);
            }
        }
 private static string GetWmsUrl(CIMWMSServiceConnection dataConnection)
 {
     if (dataConnection?.ServerConnection is CIMProjectServerConnection)
     {
         return((dataConnection?.ServerConnection as CIMProjectServerConnection).URL); // e.g. "http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi"
     }
     if (dataConnection?.ServerConnection is CIMInternetServerConnection)
     {
         return((dataConnection?.ServerConnection as CIMInternetServerConnection).URL);
     }
     return(null);
 }
예제 #4
0
        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);
                }
            });
        }