override public GraphicsLayer GetGraphicsLayer()
        {
            KmlLayer      kmlLayer      = ArcGIS_Map.Layers[LayerId.ToString()] as KmlLayer;
            GraphicsLayer graphicsLayer = GetGraphicsLayer(kmlLayer as Layer);

            return(graphicsLayer);
        }
        override public void CloseLayer()
        {
            KmlLayer shapeLayer = ArcGIS_Map.Layers[LayerId.ToString()] as KmlLayer;

            if (shapeLayer != null)
            {
                ArcGIS_Map.Layers.Remove(shapeLayer);

                if (LegendStackPanel != null)
                {
                    LegendStackPanel.Children.Clear();
                }
            }
        }
        void graphicsLayer_UpdateCompleted(object sender, EventArgs e)
        {
            FeatureLayer graphicsLayer = ArcGIS_Map.Layers[LayerId.ToString()] as FeatureLayer;

            _flagUpdateToGraphicsLayerFailed = false;

            if (graphicsLayer != null)
            {
                if (graphicsLayer.Graphics.Count > 0)
                {
                    if (FeatureLoaded != null)
                    {
                        FeatureLoaded(graphicsLayer.Url, graphicsLayer.Graphics[0].Attributes);
                    }
                }
            }

            ArcGIS_Map.Cursor = Cursors.Arrow;
        }
Exemplo n.º 4
0
        public void Init()
        {
            _uiRoot   = GameObject.Find("UIRoot");
            _uiRootTf = _uiRoot.GetComponent <RectTransform>();
            Rect rootRect = _uiRootTf.rect;

            _uiRootWidth  = rootRect.width;
            _uiRootHeight = rootRect.height;
            _uiDefaultPos = new Vector2(_uiRootWidth / 2, _uiRootHeight / 2);
            _stgLayerTf   = _uiRoot.transform.Find("GameLayer");
            _uiCamera     = _uiRoot.transform.Find("UICamera").GetComponent <Camera>();
            // UIRoot层级
            _layersMap = new Dictionary <LayerId, Transform>();
            int layerCount = (int)LayerId.LayerCount;

            for (int i = 1; i < layerCount; i++)
            {
                LayerId       tmpLayerId = (LayerId)i;
                GameObject    layerGo    = new GameObject("Layer_" + tmpLayerId.ToString());
                RectTransform layerTf    = layerGo.AddComponent <RectTransform>();
                layerTf.SetParent(_uiRootTf, false);
                layerTf.localPosition = new Vector3(0, 0, (layerCount - i) * 250);
                layerTf.anchorMin     = Vector2.zero;
                layerTf.anchorMax     = Vector2.one;
                layerTf.sizeDelta     = Vector2.zero;
                // 添加到layerMap中
                _layersMap.Add(tmpLayerId, layerTf);
            }
            if (_viewsMap == null)
            {
                _viewsMap = new Dictionary <int, ViewBase>();
            }
            if (_viewUpdateList == null)
            {
                _viewUpdateList = new List <ViewBase>();
            }
            _viewUpdateCount = 0;
            InitFocus();

            DoScreenAdaption();
        }
Exemplo n.º 5
0
 private void btnProjectAreaPrice_Click(object sender, EventArgs e)
 {
     try
     {
         List <SqlParameter> param = new List <SqlParameter>();
         param.Add(new SqlParameter("MapId", MapId));
         param.Add(new SqlParameter("LayerId", LayerId));
         param.Add(new SqlParameter("ObjectId", ObjectId));
         DataTable table     = SqlHelper.Select(SqlHelper.GetSql("SelectMaxMinProjectYear"), param);
         int       startyear = DateTime.Now.Year;
         int       endyear   = DateTime.Now.Year;
         if (table != null && table.Rows.Count > 0)
         {
             int.TryParse(table.Rows[0]["MinYear"].ToString(), out startyear);
             int.TryParse(table.Rows[0]["MaxYear"].ToString(), out endyear);
         }
         ProjectAreaPriceReportConditionForm form = new ProjectAreaPriceReportConditionForm();
         form.StartYear = startyear;
         form.EndYear   = endyear;
         if (form.ShowDialog() == DialogResult.OK)
         {
             string sql = SqlHelper.GetSql("SelectProjectAreaPrice");
             sql = sql.Replace("@StartYear", form.StartYear.ToString());
             sql = sql.Replace("@EndYear", form.EndYear.ToString());
             sql = sql.Replace("@MapId", MapId.ToString());
             sql = sql.Replace("@LayerId", LayerId.ToString());
             sql = sql.Replace("@ObjectId", ObjectId.ToString());
             ReportForm report = new ReportForm();
             report.SQL             = sql;
             report.XAxisColumnName = "估价基准日";
             report.Title           = "宗地地价走势图";
             report.GraphType       = ReportForm.ReportGraphType.Line;
             report.Show();
         }
     }
     catch (Exception ex)
     {
         Common.ShowError(ex);
     }
 }
Exemplo n.º 6
0
        override public object[] Load(string boundrySourceLocation)
        {
            if (!string.IsNullOrEmpty(boundrySourceLocation))
            {
                FileInfo shapeFile     = new FileInfo(boundrySourceLocation);
                string   directoryName = System.IO.Path.GetDirectoryName(boundrySourceLocation);
                string   dbfFilename   = System.IO.Path.GetFileName(boundrySourceLocation).ToLowerInvariant().Replace(".shp", ".dbf");
                string   dbfFullPath   = System.IO.Path.Combine(directoryName, dbfFilename);
                FileInfo dbfFile       = new FileInfo(dbfFullPath);

                if (!dbfFile.Exists)
                {
                    System.Windows.MessageBox.Show("Associated DBF file not found");
                    return(null);
                }

                ShapeFileReader.ShapeFile shapeFileReader = new ShapeFileReader.ShapeFile();
                if (shapeFile != null && dbfFile != null)
                {
                    try
                    {
                        shapeFileReader.Read(shapeFile, dbfFile);
                    }
                    catch (NotSupportedException e)
                    {
                        System.Windows.MessageBox.Show(e.Message);
                        return(null);
                    }
                    catch
                    {
                        System.Windows.MessageBox.Show(DashboardSharedStrings.DASHBOARD_MAP_N_POLYGONS_EXCEEDED);
                        return(null);
                    }
                }
                else
                {
                    System.Windows.MessageBox.Show("Please select a SP and a DBF file to proceed.");
                    return(null);
                }

                GraphicsLayer graphicsLayer = GetGraphicsLayer();

                if (graphicsLayer == null)
                {
                    graphicsLayer    = new GraphicsLayer();
                    graphicsLayer.ID = LayerId.ToString();
                    ArcGIS_Map.Layers.Add(graphicsLayer);

                    int recCount  = shapeFileReader.Records.Count;
                    int rgbFactor = 255 / recCount;
                    int counter   = 0;

                    foreach (ShapeFileReader.ShapeFileRecord record in shapeFileReader.Records)
                    {
                        Graphic graphic = record.ToGraphic();
                        if (graphic != null)
                        {
                            graphic.Symbol = GetFillSymbol(new SolidColorBrush(Color.FromArgb(240, 255, 255, 255)));
                            graphicsLayer.Graphics.Add(graphic);
                        }
                        counter += rgbFactor;
                    }
                }

                if (graphicsLayer.FullExtent == null)
                {
                    Envelope shapeFileExtent = shapeFileReader.GetExtent();
                    if (shapeFileExtent.SpatialReference == null)
                    {
                        ArcGIS_Map.Extent = shapeFileExtent;
                    }
                    else
                    {
                        if (shapeFileExtent.SpatialReference.WKID == 4326)
                        {
                            ArcGIS_Map.Extent = new Envelope(
                                ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(shapeFileExtent.XMin, shapeFileExtent.YMin)),
                                ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(shapeFileExtent.XMax, shapeFileExtent.YMax)));
                        }
                    }
                }
                else
                {
                    ArcGIS_Map.Extent = graphicsLayer.FullExtent;
                }

                graphicsLayer.RenderingMode = GraphicsLayerRenderingMode.Static;

                return(new object[] { boundrySourceLocation, graphicsLayer.Graphics[0].Attributes });
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 7
0
        override public GraphicsLayer GetGraphicsLayer()
        {
            GraphicsLayer graphicsLayer = ArcGIS_Map.Layers[LayerId.ToString()] as GraphicsLayer;

            return(graphicsLayer);
        }
        sealed override public object[] Load(string boundrySourceLocation)
        {
            if (!string.IsNullOrEmpty(boundrySourceLocation))
            {
                _kmlURL = boundrySourceLocation;
                KmlLayer shapeLayer = ArcGIS_Map.Layers[LayerId.ToString()] as KmlLayer;

                if (shapeLayer != null)
                {
                    ArcGIS_Map.Layers.Remove(shapeLayer);
                }

                shapeLayer              = new KmlLayer();
                shapeLayer.ID           = LayerId.ToString();
                shapeLayer.Url          = new Uri(boundrySourceLocation);
                shapeLayer.Initialized += new EventHandler <EventArgs>(shapeLayer_Initialized);
                ArcGIS_Map.Layers.Add(shapeLayer);

                ArcGIS_Map.Extent = shapeLayer.FullExtent;

                //KmlLayer shapeLayer = ArcGIS_Map.Layers[_layerId.ToString()] as KmlLayer;
                GraphicsLayer graphicsLayer = GetGraphicsLayer(shapeLayer);

                if (graphicsLayer != null)
                {
                    IDictionary <string, object> coreAttributes = graphicsLayer.Graphics[0].Attributes;
                    Dictionary <string, object>  allAttributes  = new Dictionary <string, object>();

                    foreach (KeyValuePair <string, object> attr in coreAttributes)
                    {
                        allAttributes.Add(attr.Key, attr.Value);
                    }

                    AddSchemaDataAttributes(_kmlURL, graphicsLayer.Graphics);

                    if (graphicsLayer.Graphics[0].Attributes.ContainsKey("extendedData"))
                    {
                        List <KmlExtendedData> eds = (List <KmlExtendedData>)graphicsLayer.Graphics[0].Attributes["extendedData"];

                        foreach (KmlExtendedData ed in eds)
                        {
                            allAttributes.Add(ed.Name, ed.Value);
                        }
                    }

                    if (FeatureLoaded != null)
                    {
                        FeatureLoaded(_kmlURL, allAttributes);
                    }


                    double xmin = graphicsLayer.Graphics[0].Geometry.Extent.XMin;
                    double xmax = graphicsLayer.Graphics[0].Geometry.Extent.XMax;
                    double ymin = graphicsLayer.Graphics[0].Geometry.Extent.YMin;
                    double ymax = graphicsLayer.Graphics[0].Geometry.Extent.YMax;

                    foreach (Graphic g in graphicsLayer.Graphics)
                    {
                        if (g.Geometry.Extent.XMin < xmin)
                        {
                            xmin = g.Geometry.Extent.XMin;
                        }

                        if (g.Geometry.Extent.YMin < ymin)
                        {
                            ymin = g.Geometry.Extent.YMin;
                        }

                        if (g.Geometry.Extent.XMax > xmax)
                        {
                            xmax = g.Geometry.Extent.XMax;
                        }

                        if (g.Geometry.Extent.YMax > ymax)
                        {
                            ymax = g.Geometry.Extent.YMax;
                        }
                    }

                    ArcGIS_Map.Extent = new Envelope(
                        ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(xmin - 0.5, ymax + 0.5)),
                        ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(xmax + 0.5, ymin - 0.5))
                        );
                }

                if (graphicsLayer == null)
                {
                    return(new object[] { boundrySourceLocation, null });
                }
                else
                {
                    return(new object[] { boundrySourceLocation, graphicsLayer.Graphics[0].Attributes });
                }
            }
            else
            {
                return(null);
            }
        }
        void shapeLayer_Initialized(object sender, EventArgs e)
        {
            KmlLayer      shapeLayer    = ArcGIS_Map.Layers[LayerId.ToString()] as KmlLayer;
            GraphicsLayer graphicsLayer = GetGraphicsLayer(shapeLayer);

            if (graphicsLayer != null)
            {
                IDictionary <string, object> coreAttributes = graphicsLayer.Graphics[0].Attributes;
                Dictionary <string, object>  allAttributes  = new Dictionary <string, object>();

                foreach (KeyValuePair <string, object> attr in coreAttributes)
                {
                    allAttributes.Add(attr.Key, attr.Value);
                }

                AddSchemaDataAttributes(_kmlURL, graphicsLayer.Graphics);

                if (graphicsLayer.Graphics[0].Attributes.ContainsKey("extendedData"))
                {
                    List <KmlExtendedData> eds = (List <KmlExtendedData>)graphicsLayer.Graphics[0].Attributes["extendedData"];

                    foreach (KmlExtendedData ed in eds)
                    {
                        allAttributes.Add(ed.Name, ed.Value);
                    }
                }

                if (FeatureLoaded != null)
                {
                    FeatureLoaded(_kmlURL, allAttributes);
                }
            }

            double xmin = graphicsLayer.Graphics[0].Geometry.Extent.XMin;
            double xmax = graphicsLayer.Graphics[0].Geometry.Extent.XMax;
            double ymin = graphicsLayer.Graphics[0].Geometry.Extent.YMin;
            double ymax = graphicsLayer.Graphics[0].Geometry.Extent.YMax;

            foreach (Graphic g in graphicsLayer.Graphics)
            {
                if (g.Geometry.Extent.XMin < xmin)
                {
                    xmin = g.Geometry.Extent.XMin;
                }

                if (g.Geometry.Extent.YMin < ymin)
                {
                    ymin = g.Geometry.Extent.YMin;
                }

                if (g.Geometry.Extent.XMax > xmax)
                {
                    xmax = g.Geometry.Extent.XMax;
                }

                if (g.Geometry.Extent.YMax > ymax)
                {
                    ymax = g.Geometry.Extent.YMax;
                }
            }

            ArcGIS_Map.Extent = new Envelope(
                ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(xmin - 0.5, ymax + 0.5)),
                ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(xmax + 0.5, ymin - 0.5))
                );
        }
        override public object[] Load(string boundrySourceLocation)
        {
            if (!string.IsNullOrEmpty(boundrySourceLocation))
            {
                FeatureLayer graphicsLayer = ArcGIS_Map.Layers[LayerId.ToString()] as FeatureLayer;
                if (graphicsLayer != null)
                {
                    ArcGIS_Map.Layers.Remove(graphicsLayer);
                }

                graphicsLayer    = new FeatureLayer();
                graphicsLayer.ID = LayerId.ToString();
                graphicsLayer.UpdateCompleted      += new EventHandler(graphicsLayer_UpdateCompleted);
                graphicsLayer.Initialized          += new EventHandler <EventArgs>(graphicsLayer_Initialized);
                graphicsLayer.InitializationFailed += new EventHandler <EventArgs>(graphicsLayer_InitializationFailed);
                graphicsLayer.UpdateFailed         += new EventHandler <TaskFailedEventArgs>(graphicsLayer_UpdateFailed);

                //if (boundrySourceLocation.Split('/')[0].Equals("NationalMap.gov - New York County Boundaries") || boundrySourceLocation.Equals("http://services.nationalmap.gov/ArcGIS/rest/services/govunits/MapServer/13"))
                //{
                //    graphicsLayer.Url = "http://services.nationalmap.gov/ArcGIS/rest/services/govunits/MapServer/13";
                //    graphicsLayer.OutFields.Add("STATE_FIPSCODE");
                //    graphicsLayer.OutFields.Add("COUNTY_NAME");
                //    graphicsLayer.Where = "STATE_FIPSCODE = '36'";
                //    ArcGIS_Map.Extent = new Envelope(ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(-80, 45.1)), ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(-71, 40)));
                //}
                //else if (boundrySourceLocation.Split('/')[0].Equals("NationalMap.gov - Rhode Island Zip Code Boundaries") || boundrySourceLocation.Equals("http://services.nationalmap.gov/ArcGIS/rest/services/govunits/MapServer/19"))
                //{
                //    graphicsLayer.Url = "http://services.nationalmap.gov/ArcGIS/rest/services/govunits/MapServer/19";
                //    graphicsLayer.OutFields.Add("STATE_FIPSCODE");
                //    graphicsLayer.OutFields.Add("NAME");
                //    graphicsLayer.Where = "STATE_FIPSCODE = '44'";
                //    ArcGIS_Map.Extent = new Envelope(ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(-72, 42.03)), ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(-71, 41)));
                //}
                //else if (boundrySourceLocation.Split('/')[0].Equals("NationalMap.gov - U.S. State Boundaries") || boundrySourceLocation.Equals("http://services.nationalmap.gov/ArcGIS/rest/services/govunits/MapServer/17"))
                //{
                //    graphicsLayer.Url = "http://services.nationalmap.gov/ArcGIS/rest/services/govunits/MapServer/17";
                //    graphicsLayer.OutFields.Add("STATE_FIPSCODE");
                //    graphicsLayer.OutFields.Add("STATE_ABBR");
                //    graphicsLayer.OutFields.Add("STATE_NAME");
                //    ArcGIS_Map.Extent = new Envelope(ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(-196, 72)), ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(-61, 14.5)));
                //}
                //else if (boundrySourceLocation.Split('/')[0].Equals("NationalMap.gov - World Boundaries"))
                //{
                //    graphicsLayer.Url = "http://services.nationalmap.gov/ArcGIS/rest/services/TNM_Blank_US/MapServer/17";
                //    ArcGIS_Map.Extent = graphicsLayer.FullExtent;
                //}
                //else
                //{
                graphicsLayer.Url = boundrySourceLocation;
                //}

                ArcGIS_Map.Layers.Add(graphicsLayer);
                ArcGIS_Map.Cursor = Cursors.Wait;

                return(new object[] { boundrySourceLocation, graphicsLayer });
            }
            else
            {
                return(null);
            }
        }