示例#1
0
        } // public string getFieldAlias(string fieldname)

        /// <summary>
        /// create Layer according to its Type
        /// </summary>
        /// <param name="id"></param>
        /// <param name="vis"></param>
        /// <returns></returns>
        private Layer createLayer(string id, bool vis)
        {
            string typ = lyrType;

            ESRI.ArcGIS.Client.Layer res = null;

            if (typ == "ArcGISTiledMapServiceLayer")
            {
                var lr = new ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer();
                lr.Url      = lyrUrl;
                lr.ProxyURL = proxy;
                res         = lr;
            }
            else if (typ == "OpenStreetMapLayer")
            {
                var lr = new ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer();
                res = lr;
            }
            else if (typ == "ArcGISDynamicMapServiceLayer")
            {
                var lr = new ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer();
                lr.Url      = lyrUrl;
                lr.ProxyURL = proxy;
                res         = lr;
            }
            else if (typ == "FeatureLayer")
            {
                var lr = new ESRI.ArcGIS.Client.FeatureLayer();
                lr.Url      = lyrUrl;
                lr.ProxyUrl = proxy;
                res         = lr;
            }
            else if (typ == "GraphicsLayer")
            {
                var gl = setContent(id, lyrUrl);
                res = gl;
            }

            if (res != null)
            {
                ESRI.ArcGIS.Client.Extensibility.LayerProperties.SetIsPopupEnabled(res, popupOn);

                // sublayers popups on/off
                if (identifyLayerIds.Length <= 3)
                {
                    ;
                }
                else
                {
                    var xmlszn = new System.Xml.Serialization.XmlSerializer(typeof(System.Collections.ObjectModel.Collection <int>));
                    var sr     = new StringReader(identifyLayerIds);
                    var ids    = xmlszn.Deserialize(sr) as System.Collections.ObjectModel.Collection <int>;
                    ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetIdentifyLayerIds(res, ids);
                }
            }

            return(res);
        } // private Layer createLayer(string id, bool vis)
示例#2
0
        public void AddPointsAsManyGraphicsLayers(List <PointDTOCollection> pointDTOList)
        {
            try
            {
                Queue <SimpleMarkerSymbol> mQueue            = this.CreateSimpleMarkerSymbolQueue();
                Queue <SimpleMarkerSymbol> markerSymbolQueue = new Queue <SimpleMarkerSymbol>(mQueue.Reverse <SimpleMarkerSymbol>());

                this.map.Layers.Clear();

                ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer openStreetMapLayer = new ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer();

                if (this.useRoads)
                {
                    openStreetMapLayer.Initialized += myOpenStreetMapLayer_Initialized;
                    map.Layers.Add(openStreetMapLayer);
                }

                foreach (PointDTOCollection pointDTOClass in pointDTOList)
                {
                    SimpleMarkerSymbol simpleMarkerSymbol;

                    //  Pick a symbol for this class
                    if (markerSymbolQueue.Count == 0)
                    {
                        mQueue            = this.CreateSimpleMarkerSymbolQueue();
                        markerSymbolQueue = new Queue <SimpleMarkerSymbol>(mQueue.Reverse <SimpleMarkerSymbol>());
                    }

                    simpleMarkerSymbol = markerSymbolQueue.Dequeue();

                    // Create a graphics layer
                    GraphicsLayer graphicsLayer = new GraphicsLayer();

                    if (pointDTOClass.Collection.Count > 1)
                    {
                        if (pointDTOList.Count > 1 && pointDTOClass.Collection.Count > 1)
                        {
                            if (pointDTOClass.Collection[0].StrataValue.Contains("\'"))
                            { // [Age] = '25'
                                graphicsLayer.ID = pointDTOClass.Collection[0].StrataValue;
                                int startPos = graphicsLayer.ID.IndexOf("=") + 3;
                                int endPos   = graphicsLayer.ID.LastIndexOf("\'");
                                graphicsLayer.ID = graphicsLayer.ID.Substring(startPos, endPos - startPos);
                            }
                            else // maybe the strata value is a # example
                                 // [Age] = 25
                            {
                                graphicsLayer.ID = pointDTOClass.Collection[0].StrataValue;
                                int startPos = graphicsLayer.ID.IndexOf("=") + 1;
                                int endPos   = graphicsLayer.ID.Length;
                                graphicsLayer.ID = graphicsLayer.ID.Substring(startPos, endPos - startPos);
                            }
                        }
                        else
                        {
                            graphicsLayer.ID = pointDTOClass.Collection[0].StrataValue;
                        }
                    }

                    EwavLegendItemData eli = new EwavLegendItemData();
                    eli.Color       = simpleMarkerSymbol.Color;
                    eli.Description = graphicsLayer.ID;

                    this.ewavLegendItemList.Add(eli);

                    // Create a clusterer with a flare
                    FlareClusterer fc = new FlareClusterer();
                    fc.FlareBackground   = simpleMarkerSymbol.Color;
                    fc.MaximumFlareCount = this.maximumFlareCount;  // 20
                    fc.Radius            = this.flareClusterRadius; //  += fc.Radius / 10;

                    // Add clusterer to graphics layer
                    graphicsLayer.Clusterer = fc;

                    // Add graphics to graphics layer with
                    foreach (PointDTO pointDTO in pointDTOClass.Collection)
                    {
                        Graphic graphic   = this.createGraphic(pointDTO, simpleMarkerSymbol);
                        Border  brdmaptip = new Border();
                        brdmaptip.Background      = new SolidColorBrush(Colors.White);
                        brdmaptip.BorderBrush     = simpleMarkerSymbol.Color;
                        brdmaptip.BorderThickness = new Thickness(1, 1, 1, 1);

                        // Create a map tip
                        TextBlock tb = new TextBlock();

                        // if multiple cols are required for map tips later,
                        // use of pointDTO.MapTip will facilitate it.
                        tb.Text         = graphicsLayer.ID; // pointDTO.MapTip;
                        tb.Margin       = new Thickness(5, 5, 5, 5);
                        brdmaptip.Child = tb;

                        graphic.MapTip = brdmaptip;
                        graphic.MapTip.VerticalAlignment   = VerticalAlignment.Top;
                        graphic.MapTip.HorizontalAlignment = HorizontalAlignment.Right;

                        graphicsLayer.Graphics.Add(graphic);
                    }



                    // Add graphics layer to map
                    this.map.Layers.Add(graphicsLayer);
                    this.map.Extent = graphicsLayer.FullExtent;
                    this.map.Zoom(.9);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("{0} == {1}", ex.Message, ex.StackTrace));
            }
        }
示例#3
0
 private void myOpenStreetMapLayer_Initialized(object sender, EventArgs e)
 {
     // Get the OpenStreetMapLayer.
     ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer myOpenStreetMapLayer = (ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer)sender;
 }
示例#4
0
        }         // public void initRelations()

        private Layer createLayer(string id, bool vis)
        {
            // create Layer according to its Type
            string typ = lyrType;

            ESRI.ArcGIS.Client.Layer res = new ESRI.ArcGIS.Client.GraphicsLayer();

            if (typ == "ArcGISTiledMapServiceLayer")
            {
                var lr = new ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer();
                lr.Url      = lyrUrl;
                lr.ProxyURL = proxy;
                res         = lr;
            }
            else if (typ == "OpenStreetMapLayer")
            {
                var lr = new ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer();
                res = lr;
            }
            else if (typ == "ArcGISDynamicMapServiceLayer")
            {
                var lr = new ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer();
                lr.Url         = lyrUrl;
                lr.ProxyURL    = proxy;
                lr.ImageFormat = imageFormat;
                res            = lr;
            }
            else if (typ == "FeatureLayer")
            {
                var lr = new ESRI.ArcGIS.Client.FeatureLayer()
                {
                    Url = lyrUrl, ProxyUrl = proxy
                };
                lr.OutFields.Add("*");
                lr.Mode = FeatureLayer.QueryMode.OnDemand;
                lr.Initialize();                 // retrieve attribs from server
                var rr = rendererFromJson(renderer);
                if (rr != null)
                {
                    lr.Renderer = rr;
                }
                res = lr;
            }
            else if (typ == "GraphicsLayer")
            {
                var gl = setContent(id, lyrUrl);
                var rr = rendererFromJson(renderer);
                if (rr != null)
                {
                    gl.Renderer = rr;
                }
                res = gl;
            }

            if (res != null)
            {
                ESRI.ArcGIS.Client.Extensibility.LayerProperties.SetIsPopupEnabled(res, popupOn);

                // sublayers popups on/off
                if (identifyLayerIds.Length <= 3)
                {
                    ;
                }
                else
                {
                    var xmlszn = new System.Xml.Serialization.XmlSerializer(typeof(System.Collections.ObjectModel.Collection <int>));
                    var sr     = new StringReader(identifyLayerIds);
                    var ids    = xmlszn.Deserialize(sr) as System.Collections.ObjectModel.Collection <int>;
                    ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetIdentifyLayerIds(res, ids);
                }
            }

            return(res);
        }         // private Layer createLayer(string id, bool vis)