Exemplo n.º 1
0
 private void Client_GetAllSitesCompleted(object sender, GetAllSitesCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         CurrentAction       = UserAction.Idle;
         GeneralInfo.Content = "Failed to search sites";
         return;
     }
     if (e.Result != null)
     {
         foreach (GraphicsLayer layer in _GraphicsLayers.Values)
         {
             layer.Graphics.Clear();
         }
         foreach (var s in e.Result)
         {
             Graphic  graphic = new Graphic();
             double[] lonlat  = SpatialReferenceSystem.ToWebMercator(s.Longitude, s.Latitude);
             graphic.Geometry = new MapPoint(lonlat[0], lonlat[1]);
             graphic.Symbol   = _MarkerSymbols[s.SiteType];;
             graphic.Attributes.Add("Name", s.Name);
             graphic.Attributes.Add("Site", s);
             _GraphicsLayers[s.SiteType].Graphics.Add(graphic);
         }
         CurrentAction       = UserAction.Idle;
         GeneralInfo.Content = e.Result.Count + " sites found";
     }
     else
     {
         CurrentAction       = UserAction.Idle;
         GeneralInfo.Content = "No sites found";
     }
 }
Exemplo n.º 2
0
        public void Creat(GraphicsLayer layer, RegularGrid grid)
        {
            _GraphicsLayer = layer;
            var cellsize = grid.CellSize * 0.5;
            var polygon  = new Polygon();

            for (int i = 0; i < grid.NCell; i++)
            {
                var symbol = GetDefaultSymbol(polygon, System.Windows.Media.Colors.White);
                ESRI.ArcGIS.Client.Geometry.PointCollection pc = new ESRI.ArcGIS.Client.Geometry.PointCollection();
                var      buf = SpatialReferenceSystem.ToWebMercator(grid.CentroidX[i] - cellsize, grid.CentroidY[i] + cellsize);
                MapPoint p1  = new MapPoint(buf[0], buf[1]);
                buf = SpatialReferenceSystem.ToWebMercator(grid.CentroidX[i] + cellsize, grid.CentroidY[i] + cellsize);
                MapPoint p2 = new MapPoint(buf[0], buf[1]);
                buf = SpatialReferenceSystem.ToWebMercator(grid.CentroidX[i] + cellsize, grid.CentroidY[i] - cellsize);
                MapPoint p3 = new MapPoint(buf[0], buf[1]);
                buf = SpatialReferenceSystem.ToWebMercator(grid.CentroidX[i] - cellsize, grid.CentroidY[i] - cellsize);
                MapPoint p4 = new MapPoint(buf[0], buf[1]);
                buf = SpatialReferenceSystem.ToWebMercator(grid.CentroidX[i] - cellsize, grid.CentroidY[i] + cellsize);
                MapPoint p5 = new MapPoint(buf[0], buf[1]);
                pc.Add(p1);
                pc.Add(p2);
                pc.Add(p3);
                pc.Add(p4);
                pc.Add(p5);
                Graphic graphic = new Graphic();
                Polygon ep      = new Polygon();
                ep.Rings.Add(pc);
                graphic.Geometry = ep;
                graphic.Symbol   = symbol;
                graphic.Attributes.Add("ID", i);
                layer.Graphics.Add(graphic);
            }
        }