private void OnGraphicAddClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                GraphicsLayer gLayer = map1.Layers["EventsGraphicsLayer"] as GraphicsLayer;
                if (gLayer != null)
                    map1.Layers.Remove(gLayer);

                GraphicsLayer graphicsLayer = new GraphicsLayer()
                {
                    ID = "SimpleGraphicsLayer"
                };

                graphicsLayer.Graphics.Add(new Graphic()
                {
                    Geometry = new MapPoint(-74.0064, 40.7142),
                    Symbol = new SimpleMarkerSymbol()
                    {
                        Style = SimpleMarkerStyle.Circle,
                        Color = Colors.Red,
                        Size = 8
                    }
                });
                map1.Layers.Add(graphicsLayer);
            }
            catch (Exception ex)
            {

                throw;
            }
        }
Ejemplo n.º 2
0
 public void Start()
 {
     if (circleLayer != null) return;
     circleLayer = new GraphicsLayer { ID = Id, IsHitTestVisible = false };
     circleLayer.Initialize();
     ((dsBaseLayer)Layer).ChildLayers.Insert(0, circleLayer);
 }
        public Intersect()
        {
            InitializeComponent();

            MyMap.Layers.LayersInitialized += Layers_LayersInitialized;

            MyMap.MinimumResolution = double.Epsilon;

            MyDrawObject = new Draw(MyMap)
            {
                DrawMode = DrawMode.Polygon,
                IsEnabled = false,
                FillSymbol = LayoutRoot.Resources["CyanFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol
            };
            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;

            parcelGraphicsLayer = MyMap.Layers["ParcelsGraphicsLayer"] as GraphicsLayer;
            intersectGraphicsLayer = MyMap.Layers["IntersectGraphicsLayer"] as GraphicsLayer;

            geometryService =
              new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

            geometryService.SimplifyCompleted += GeometryService_SimplifyCompleted;
            geometryService.IntersectCompleted += GeometryService_IntersectCompleted;
            geometryService.Failed += GeometryService_Failed;

            random = new Random();
        }
Ejemplo n.º 4
0
 public void Start()
 {
     if (ZonesLayer != null) return;
     ZonesLayer = new GraphicsLayer { ID = Id };
     ZonesLayer.Initialize();
     ((dsBaseLayer)Layer).ChildLayers.Insert(0, ZonesLayer);
 }
Ejemplo n.º 5
0
            /// <summary>
            /// Initializes a new instance of the MainViewModel class.
            /// </summary>
            public MainViewModel()
            {
                if (IsInDesignMode)
                {
                    // Code runs in Blend --> create design time data.
                }
                else
                {
                    // Code runs "for real"
                    ConfigService config = new ConfigService();
                    this.myModel = config.LoadJSON();
                    this.SearchRelayCommand = new RelayCommand<string>(Search);

                    Messenger.Default.Register<Esri.ArcGISRuntime.Controls.MapView>(this, (mapView) =>
                    {
                        this.mapView = mapView;
                        this.mapView.MaxScale = 500;

                        ArcGISLocalTiledLayer localTiledLayer = new ArcGISLocalTiledLayer(this.TilePackage);
                        localTiledLayer.ID = "SF Basemap";
                        localTiledLayer.InitializeAsync();

                        this.mapView.Map.Layers.Add(localTiledLayer);

                        this.CreateLocalServiceAndDynamicLayer();
                        this.CreateFeatureLayers();

                        this.graphicsLayer = new Esri.ArcGISRuntime.Layers.GraphicsLayer();
                        this.graphicsLayer.ID = "Results";
                        this.graphicsLayer.InitializeAsync();
                        this.mapView.Map.Layers.Add(this.graphicsLayer);
                    });
                }
            }
        public LineLength()
        {
            InitializeComponent();

            mapView1.Map.InitialExtent = new Envelope(-13149423, 3997267, -12992880, 4062214, SpatialReferences.WebMercator);
            myGraphicsLayer = mapView1.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
        }
        /// <summary>Construct Graphics Hit Testing sample control</summary>
        public GraphicsHitTesting()
        {
            InitializeComponent();

			_graphicsLayer = MyMapView.Map.Layers["graphicsLayer"] as GraphicsLayer;
			MyMapView.ExtentChanged += MyMapView_ExtentChanged;
        }
        private void AddSampleGraphic(GraphicsLayer gLyr)
        {
            SimpleMarkerSymbol sampleSymbol = new SimpleMarkerSymbol()
            {
                Color = new SolidColorBrush(Colors.Red),
                Size = 12,
                Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle
            };

            Graphic g = new Graphic()
            {
                Geometry = new MapPoint(-110, 35),
                Symbol = sampleSymbol
            };
            g.Attributes.Add("Attribute1", "Value1");
            g.Attributes.Add("Attribute2", "Value2");
            g.Attributes.Add("Attribute3", "Value3");
            g.Attributes.Add("Attribute4", "Value4");
            g.Attributes.Add("Attribute5", "Value5");
            g.Attributes.Add("Attribute6", "Value6");
            g.Attributes.Add("Attribute7", "Value7");
            g.Attributes.Add("Attribute8", "Value8");
            g.Attributes.Add("Attribute9", "Value9");
            g.Attributes.Add("Attribute10", "Value10");

            gLyr.Graphics.Add(g);
        }
		/// <summary>Construct Graphics Source sample control</summary>
		public GraphicsSourceSample()
		{
			InitializeComponent();

			_graphicsLayer = MyMapView.Map.Layers["graphicsLayer"] as GraphicsLayer;
			MyMapView.NavigationCompleted += MyMapView_NavigationCompleted;
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="SmoothGraphicAnimation"/> class.
        /// </summary>
        public SmoothGraphicAnimation()
        {
            InitializeComponent();

            _userInteractionLayer = new GraphicsLayer()
            {
                Renderer = new SimpleRenderer()
                {
                    Symbol = new SimpleMarkerSymbol() { Color = Colors.Green, Size = 12, Style = SimpleMarkerStyle.Circle }
                }
            };

            _animatingLayer = new GraphicsLayer()
            {
                Renderer = new SimpleRenderer()
                {
                    Symbol = new SimpleMarkerSymbol() { Color = Colors.Red, Size = 12, Style = SimpleMarkerStyle.Circle }
                }
            };

            PropertyChangedEventHandler propertyChanged = null;
            propertyChanged += (s, e) =>
            {
                if (e.PropertyName == "SpatialReference")
                {
                    mapView1.PropertyChanged -= propertyChanged;
                    AddLayers();
                    WaitforMapClick();                    
                }
            };
            mapView1.PropertyChanged += propertyChanged;
        }
        /// <summary>Construct Create Polygons sample control</summary>
        public CreatePolygons()
        {
            InitializeComponent();

            graphicsLayer = mapView.Map.Layers["GraphicsLayer"] as GraphicsLayer;
            var task = CreatePolygonGraphics();
        }
        /// <summary>Construct Geodesic Buffer sample control</summary>
        public GeodesicBuffer()
        {
            InitializeComponent();

            _graphicsLayer = mapView.Map.Layers["GraphicsLayer"] as GraphicsLayer;
            var task = SetupSymbols();
        }
        string serializeLayer(GraphicsLayer layer)
        {

            Dictionary<string, string> Namespaces = new Dictionary<string, string>();
            Namespaces.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
            Namespaces.Add(ESRI.ArcGIS.Mapping.Core.Constants.esriPrefix, ESRI.ArcGIS.Mapping.Core.Constants.esriNamespace);
            Namespaces.Add("esriBing", "clr-namespace:ESRI.ArcGIS.Client.Bing;assembly=ESRI.ArcGIS.Client.Bing");
            Namespaces.Add(ESRI.ArcGIS.Mapping.Core.Constants.esriMappingPrefix, ESRI.ArcGIS.Mapping.Core.Constants.esriMappingNamespace);
            Namespaces.Add(ESRI.ArcGIS.Mapping.Core.Constants.esriFSSymbolsPrefix, ESRI.ArcGIS.Mapping.Core.Constants.esriFSSymbolsNamespace);
			Namespaces.Add(ESRI.ArcGIS.Mapping.Core.Constants.esriExtensibilityPrefix, ESRI.ArcGIS.Mapping.Core.Constants.esriExtensibilityNamespace);

            StringBuilder xaml = new StringBuilder();
            XmlWriter writer = XmlWriter.Create(xaml, new XmlWriterSettings() { OmitXmlDeclaration = true });
            writer.WriteStartElement("ContentControl");

            // write namespaces
            foreach (string key in Namespaces.Keys)
            {
                string _namespace = "http://schemas.microsoft.com/winfx/2006/xaml"; // default
                if (Namespaces.ContainsKey(key))
                    _namespace = Namespaces[key];
                writer.WriteAttributeString("xmlns", key, null, _namespace);
            }
            ESRI.ArcGIS.Mapping.Core.GraphicsLayerXamlWriter layerWriter = new Core.GraphicsLayerXamlWriter(writer, Namespaces);
            layerWriter.WriteLayer(layer, layer.GetType().Name, ESRI.ArcGIS.Mapping.Core.Constants.esriNamespace);

            writer.WriteEndElement();

            writer.Flush();
            writer = null;
            string config = xaml.ToString();
            // Inject default namespace
            config = config.Insert(16, "xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" ");
            return config;
        }
        void addInput(ESRI.ArcGIS.Client.Geometry.Geometry geometry)
        {
            GraphicsLayer layer = getLayer();

            #region Create layer if not already there and add to map
            if (layer == null)
            {
                InputLayerID = Guid.NewGuid().ToString("N");
                layer = new GraphicsLayer();
                if (config.Layer != null)
                {
                    layer.Renderer = config.Layer.Renderer;
                    Core.LayerExtensions.SetFields(layer, Core.LayerExtensions.GetFields(config.Layer));
                    Core.LayerExtensions.SetGeometryType(layer, Core.LayerExtensions.GetGeometryType(config.Layer));
                    Core.LayerExtensions.SetDisplayField(layer, Core.LayerExtensions.GetDisplayField(config.Layer));
                    Core.LayerExtensions.SetPopUpsOnClick(layer, Core.LayerExtensions.GetPopUpsOnClick(config.Layer));
                    LayerProperties.SetIsPopupEnabled(layer, LayerProperties.GetIsPopupEnabled(config.Layer));
                }
                layer.ID = InputLayerID;

                layer.SetValue(MapApplication.LayerNameProperty,
                    string.IsNullOrEmpty(config.LayerName) ? 
                        string.IsNullOrEmpty(config.Label) ? config.Name : config.Label
                        : config.LayerName);
                layer.Opacity = config.Opacity;
                Map.Layers.Add(layer);
            }
            #endregion

            #region Add geometry to layer
            Graphic g = new Graphic() { Geometry = geometry };
            layer.Graphics.Add(g);
            #endregion
        }
        public GraphicsSourceSample()
        {
            this.InitializeComponent();

            _graphicsLayer = MyMapView.Map.Layers["GraphicsLayer"] as GraphicsLayer;
            CreateGraphics();
        }
 public FindAnAddress()
 {
     this.InitializeComponent();
     MyMap.InitialExtent = GeometryEngine.Project(new Envelope(-122.554, 37.615, -122.245, 37.884, SpatialReference.Wgs84),
         SpatialReference.WebMercator) as Envelope;
     _candidateGraphicsLayer = MyMap.Layers["CandidateGraphicsLayer"] as GraphicsLayer;
 }
 public CalculateViewshed()
 {
     InitializeComponent();
     InitializePMS().ContinueWith((_) => { }, TaskScheduler.FromCurrentSynchronizationContext());
     mapView1.Map.InitialExtent = new Envelope(-12004035.9462375, 4652780.19374956, -11735714.4261546, 4808810.41937776);
     inputLayer = mapView1.Map.Layers["InputLayer"] as GraphicsLayer;
 }
Ejemplo n.º 18
0
        public DriveTimes()
        {
            InitializeComponent();

            graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            bufferSymbols = new List<FillSymbol>(
                    new FillSymbol[] { LayoutRoot.Resources["FillSymbol1"] as FillSymbol,
                        LayoutRoot.Resources["FillSymbol2"] as FillSymbol,
                        LayoutRoot.Resources["FillSymbol3"] as FillSymbol });

            _geoprocessorTask = new Geoprocessor("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/GPServer/Generate%20Service%20Areas");
            _geoprocessorTask.JobCompleted += GeoprocessorTask_JobCompleted;
            _geoprocessorTask.StatusUpdated += GeoprocessorTask_StatusUpdated;
            _geoprocessorTask.GetResultDataCompleted += GeoprocessorTask_GetResultDataCompleted;
            _geoprocessorTask.Failed += GeoprocessorTask_Failed;

            MyDrawObject = new Draw(MyMap)
            {
                IsEnabled = true,
                DrawMode = DrawMode.Point
            };

            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
        }
Ejemplo n.º 19
0
        public MainPage()
        {
            InitializeComponent();

            activateIdentify = true;

            MyDrawObject = new Draw(myMap)
            {
                FillSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol,
                DrawMode = DrawMode.Rectangle

            };

            MyDrawObject.DrawComplete += myDrawObject_DrawComplete;
            MyDrawObject.IsEnabled = false;
            _toolMode = "";
            _previousExtentImage = btnPrevExtent.Content as Image;
            _nextExtentImage = btnNextExtent.Content as Image;

            // Initializes the graphics layer
            graphicsLayer = myMap.Layers["myGraphicsLayer"] as GraphicsLayer;

            myMeasureObject = new Draw(myMap)
            {
                // Sets the initial drawing of the line and polygon
                FillSymbol = LayoutRoot.Resources["RedFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol,
                LineSymbol = LayoutRoot.Resources["RedLineSymbol"] as ESRI.ArcGIS.Client.Symbols.CartographicLineSymbol
            };

            // Runs the measure draw complete method
            myMeasureObject.DrawComplete += myMeasureObject_DrawComplete;
            // Disables the measure drawing once a graphic is drawn - in other words, I don't want to draw multiple graphics
            myMeasureObject.IsEnabled = false;
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="SmoothGraphicAnimation"/> class.
		/// </summary>
		public SmoothGraphicAnimation()
		{
			InitializeComponent();

			_userInteractionLayer = new GraphicsLayer()
			{
				Renderer = new SimpleRenderer()
				{
					Symbol = new SimpleMarkerSymbol() { Color = Colors.Green, Size = 15, Style = SimpleMarkerStyle.Circle }
				}
			};

			_animatingLayer = new GraphicsLayer()
			{
				Renderer = new SimpleRenderer()
				{
					Symbol = new SimpleMarkerSymbol() { Color = Colors.Red, Size = 15, Style = SimpleMarkerStyle.Circle }
				}
			};

            MyMapView.Map.Layers.Add(_userInteractionLayer);
            MyMapView.Map.Layers.Add(_animatingLayer);

            MyMapView.SpatialReferenceChanged += MyMapView_SpatialReferenceChanged;
        }
Ejemplo n.º 21
0
 public void drawBufferCircle(double radius, int pointCount, MapPoint currentPoint, GraphicsLayer gl)
 {
     MapPoint point = currentPoint;
     var pl = new ESRI.ArcGIS.Client.Geometry.Polyline();
     var polygon = new ESRI.ArcGIS.Client.Geometry.Polygon();
     var routePoint = new ESRI.ArcGIS.Client.Geometry.PointCollection();
     for (int i = 1; i <= pointCount; i++)
     {
         double x;
         double y;
         x = (point.X + radius * Math.Cos(2 * Math.PI / pointCount * i));
         y = (point.Y + radius * Math.Sin(2 * Math.PI / pointCount * i));
         routePoint.Add(new MapPoint(x, y));
     }
     routePoint.Add(routePoint[0]);
     polygon.Rings.Add(routePoint);
     GraphicsLayer mygraphicslayer = gl;
     mygraphicslayer.ClearGraphics();
     Graphic graphic = new Graphic()
     {
         Geometry = polygon,
         Symbol = LayoutRoot.Resources["DefaultBufferSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
     };
     mygraphicslayer.Graphics.Add(graphic);
 }
        public BatchGeocoding()
        {
            InitializeComponent();

            ESRI.ArcGIS.Client.Geometry.Envelope initialExtent =
                        new ESRI.ArcGIS.Client.Geometry.Envelope(
                    _mercator.FromGeographic(
                        new ESRI.ArcGIS.Client.Geometry.MapPoint(-117.387, 33.97)) as MapPoint,
                    _mercator.FromGeographic(
                        new ESRI.ArcGIS.Client.Geometry.MapPoint(-117.355, 33.988)) as MapPoint);

            initialExtent.SpatialReference = new SpatialReference(102100);

            MyMap.Extent = initialExtent;

            _locatorTask = new Locator("http://serverapps101.esri.com/arcgis/rest/services/USA_Geocode/GeocodeServer");
            _locatorTask.AddressesToLocationsCompleted += _locatorTask_AddressesToLocationsCompleted;
            _locatorTask.Failed += LocatorTask_Failed;

            geocodedResults = MyMap.Layers["LocationGraphicsLayer"] as GraphicsLayer;

            //List of addresses to geocode
            batchaddresses.Add(new Dictionary<string, string> { { "Street", "4409 Redwood Dr" }, { "Zip", "92501" } });
            batchaddresses.Add(new Dictionary<string, string> { { "Street", "3758 Cedar St" }, { "Zip", "92501" } });
            batchaddresses.Add(new Dictionary<string, string> { { "Street", "3486 Orange St" }, { "Zip", "92501" } });
            batchaddresses.Add(new Dictionary<string, string> { { "Street", "2999 4th St" }, { "Zip", "92507" } });
            batchaddresses.Add(new Dictionary<string, string> { { "Street", "3685 10th St" }, { "Zip", "92501" } });

            AddressListbox.ItemsSource = batchaddresses;
        }
Ejemplo n.º 23
0
 public void Start()
 {
     if (explosionLayer != null) return;
     explosionLayer = new GraphicsLayer { ID = Id };
     explosionLayer.Initialize();
     ((dsBaseLayer)Layer).ChildLayers.Insert(0, explosionLayer);
 }
        public Routing()
        {
            InitializeComponent();

            stopsGraphicsLayer = MyMap.Layers["MyStopsGraphicsLayer"] as GraphicsLayer;
            routeGraphicsLayer = MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer;
            routeTask = LayoutRoot.Resources["MyRouteTask"] as RouteTask;
        }
        /// <summary>Construct Line and Fill Symbols sample control</summary>
        public LineFillSymbols()
        {
            InitializeComponent();

            _graphicsLayer = mapView.Map.Layers["GraphicsLayer"] as GraphicsLayer;

            mapView.ExtentChanged += mapView_ExtentChanged;
        }
		public Distance()
		{
			InitializeComponent();

			MyMapView.Map.InitialViewpoint = new Viewpoint(new Envelope(-117.5, 32.5, -116.5, 35.5, SpatialReferences.Wgs84));
			inputGraphicsLayer = MyMapView.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;

		}
		public CalculateViewshed()
		{
			InitializeComponent();
			InitializePMS();
			MyMapView.Map.InitialViewpoint = new Viewpoint(new Envelope(-12004036, 4652780, -11735714, 4808810));
			inputLayer = MyMapView.Map.Layers["InputLayer"] as GraphicsLayer;
			viewshedLayer = MyMapView.Map.Layers["viewShedLayer"] as GraphicsLayer;
		}
        /// <summary>Construct Class Breaks Renderer sample control</summary>
        public ClassBreaksRendererSample()
        {
            InitializeComponent();

            _earthquakes = mapView.Map.Layers["Earthquakes"] as GraphicsLayer;
                
            mapView.ExtentChanged += mapView_ExtentChanged;
        }
 public ViewShed()
 {
     InitializeComponent();
       _geoprocessorTask = new Geoprocessor("http://serverapps101.esri.com/arcgis/rest/services/ProbabilisticViewshedModel/GPServer/ProbabilisticViewshedModel");
       _geoprocessorTask.JobCompleted += GeoprocessorTask_JobCompleted;
       _geoprocessorTask.Failed += GeoprocessorTask_Failed;
       graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Started only once in a service
 /// </summary>
 public void Start()
 {
     if (QueryLayer != null) return;
     QueryLayer = new GraphicsLayer { ID = Id };
     QueryLayer.Initialize();
     var dsBaseLayer = (dsBaseLayer)Layer;
     if (dsBaseLayer != null) dsBaseLayer.ChildLayers.Insert(0, QueryLayer);
 }
 private void CircleConSelectCallback(GraphicsLayer gLayer, IGraphics graphics, List <Point> logPntArr)
 {
     if (logPntArr.Count > 1)
     {
         Circle obj = new Circle();
         obj.Center = new Dot_2D()
         {
             x = logPntArr[0].X,
             y = logPntArr[0].Y
         };
         obj.Radius = Math.Sqrt(Math.Pow(logPntArr[0].X - logPntArr[1].X, 2) + Math.Pow(logPntArr[0].Y - logPntArr[1].Y, 2));
         m_conditionInput.SelectionType = SelectionType.Both;
         m_conditionInput.QueryGeoObj   = obj;
         m_conditionInput.Show();
     }
 }
Ejemplo n.º 32
0
        public BufferQuery()
        {
            InitializeComponent();

            _geometryService =
                new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
            _geometryService.BufferCompleted += GeometryService_BufferCompleted;
            _geometryService.Failed          += GeometryService_Failed;

            _queryTask = new QueryTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer/2");
            _queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
            _queryTask.Failed           += QueryTask_Failed;

            _pointAndBufferGraphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            _resultsGraphicsLayer        = MyMap.Layers["MyResultsGraphicsLayer"] as GraphicsLayer;
        }
        public Offset()
        {
            InitializeComponent();

            MyMapView.Map.InitialViewpoint = new Viewpoint(new Envelope(-9275076, 5253226, -9274274, 5253886, SpatialReferences.WebMercator));
            parcelGraphicsLayer            = MyMapView.Map.Layers["ParcelsGraphicsLayer"] as GraphicsLayer;
            offsetGraphicsLayer            = MyMapView.Map.Layers["OffsetGraphicsLayer"] as GraphicsLayer;

            InitializeOffsetTypes();
            OffsetDistanceSlider.ValueChanged     += Slider_ValueChanged;
            OffsetTypeComboBox.SelectionChanged   += ComboBox_SelectionChanged;
            OffsetFlattenErrorSlider.ValueChanged += Slider_ValueChanged;
            OffsetBevelRatioSlider.ValueChanged   += Slider_ValueChanged;

            ControlsContainer.Visibility = Visibility.Collapsed;
        }
Ejemplo n.º 34
0
 protected EllipsoidalAreaViewModel()
 {
     this.DockEnabled      = true;
     this.GeometryUtil     = new GeometryUtility();
     this.GeodesicAreaInfo = "Graphic Area:";
     //this._cmdClearGraphics = new RelayCommand(() => this.RemoveDrawnGraphics(), () => this.CanClearGraphics());
     this._cmdClearGraphics = new RelayCommand(() => this.CheckAndRemoveGraphicLayer(), () => this.CanClearGraphics());
     this.CmdRemoveSelected = new RelayCommand(() => this.RemoveSelectedGraphic(), () => this.CanRemoveGraphics());
     this.CmdUnitChanged    = new RelayCommand(() => this.HandleUnitChanged(), () => { return(true); });
     this.MapViewUtil       = new MapViewUtility();
     //From this constructor , it does not reach/notify the binding of properties to UI
     this.BuildUiBindedProperties();
     this.CurrentGraphicList    = new List <IDisposable>();
     this._PolygonGraphicsLayer = null;
     this._esriLayoutSelect     = FrameworkApplication.GetPlugInWrapper(DAML.Tool.esri_layouts_selectByRectangleTool) as ICommand;
 }
Ejemplo n.º 35
0
 // Zooms to the passed-in graphics layer
 private void zoomToGraphicsLayer(GraphicsLayer layer)
 {
     if (layer.Graphics.Count == 1) // Just pan if only one
     {
         m_mapView.SetView((MapPoint)layer.Graphics.First().Geometry);
     }
     else if (layer.Graphics.Count > 1)
     {
         // Get envelope and zoom if more than one
         Envelope extent = getGraphicsLayerExtent(layer);
         if (extent != null)
         {
             m_mapView.SetView(extent.Expand(2));
         }
     }
 }
        /// <summary>
        /// 添加预定义样式点对象
        /// </summary>
        /// <param name="logPntArr"></param>
        private void mark(GraphicsLayer gLayer, IGraphics graphics, List <Point> logPntArr)
        {
            //初始化点样式对象
            _markStyle = new IMSSimpleMarkerSymbol();
            //设置点显示样式
            _markStyle.SymbolStyle = this.markType;
            _markStyle.Size        = 20;//点大小
            //添加点样式到标注里面
            IMSMark mark = new IMSMark(_markStyle.control, ZDIMS.Interface.CoordinateType.Logic);

            //设置坐标
            mark.X = logPntArr[0].X;
            mark.Y = logPntArr[0].Y;
            mark.EnableAnimation = false; //不允许动态变换
            this.markLayer.AddMark(mark); //添加点样式
        }
Ejemplo n.º 37
0
        public override bool CanExecute(object parameter)
        {
            if (Layer == null)
            {
                return(false);
            }

            GraphicsLayer graphicsLayer = Layer as GraphicsLayer;

            if (graphicsLayer == null)
            {
                return(false);
            }

            return(graphicsLayer.SelectedGraphics.Count() > 0);
        }
        public TrimExtend()
        {
            InitializeComponent();

            polylineLayer = MyMap.Layers["MyPolylineGraphicsLayer"] as GraphicsLayer;
            resultsLayer  = MyMap.Layers["MyResultsGraphicsLayer"] as GraphicsLayer;
            MyMap.Layers.LayersInitialized += Layers_LayersInitialized;

            MyDrawObject = new Draw(MyMap)
            {
                DrawMode   = DrawMode.Polyline,
                IsEnabled  = true,
                LineSymbol = LayoutRoot.Resources["DrawLineSymbol"] as ESRI.ArcGIS.Client.Symbols.LineSymbol
            };
            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GeocodeFullAddressInput"/> class.
        /// </summary>
        public GeocodeFullAddressInput()
        {
            InitializeComponent();

            DataContext = this;

            // Min X,Y = -13,044,000  3,855,000 Meters
            // Max X,Y = -13,040,000  3,858,000 Meters
            map1.InitialExtent = new Envelope(-13044000, 3855000, -13040000, 3858000, webMercator);

            SetupLocator();

            _candidateAddressesGraphicsLayer = map1.Layers["CandidateAddressesGraphicsLayer"] as GraphicsLayer;

            SetSimpleRendererSymbols();
        }
        // Auto-initializes the popup title for the targeted layer
        private void autoInitPopupTitle(GraphicsLayer layer)
        {
            if (layer == null)
            {
                return;
            }

            // Auto-detect the display field for the layer
            string fieldName = findDisplayField(Target as GraphicsLayer);

            // Use the display field for the popup title
            if (!string.IsNullOrEmpty(fieldName))
            {
                setPopupTitle(fieldName, layer);
            }
        }
        public override void Execute(object parameter)
        {
            if (Layer == null)
            {
                return;
            }

            GraphicsLayer graphicsLayer = Layer as GraphicsLayer;

            if (graphicsLayer == null)
            {
                return;
            }

            showFindNearbyToolWindow();
        }
        void defaultSymbolConfig_DefaultSymbolModified(object sender, SymbolSelectedEventArgs e)
        {
            GraphicsLayer graphicsLayer = Layer as GraphicsLayer;

            if (graphicsLayer == null)
            {
                return;
            }

            graphicsLayer.ChangeRenderer(e.Symbol);
            refreshLayer();
            if (SymbolConfigControl != null)
            {
                SymbolConfigControl.Symbol = e.Symbol;
            }
        }
Ejemplo n.º 43
0
        public RoutingBarriers()
        {
            InitializeComponent();

            _routeTask =
                new RouteTask("http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route");
            _routeTask.SolveCompleted += routeTask_SolveCompleted;
            _routeTask.Failed         += routeTask_Failed;

            _routeParams.Stops          = _stops;
            _routeParams.Barriers       = _barriers;
            _routeParams.UseTimeWindows = false;

            barriersLayer = MyMap.Layers["MyBarriersGraphicsLayer"] as GraphicsLayer;
            stopsLayer    = MyMap.Layers["MyStopsGraphicsLayer"] as GraphicsLayer;
        }
        void GeometryService_DifferenceCompleted(object sender, GraphicsEventArgs e)
        {
            outputGraphicsLayer = MyMap.Layers["OutputGraphicsLayer"] as GraphicsLayer;
            outputGraphicsLayer.Graphics.Clear();
            foreach (Graphic g in e.Results)
            {
                if (g.Geometry is Polygon)
                {
                    g.Symbol = LayoutRoot.Resources["DifferenceFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                }
                outputGraphicsLayer.Graphics.Add(g);
            }

            MyDrawObject.IsEnabled = true;
            ResetButton.IsEnabled  = true;
        }
Ejemplo n.º 45
0
        public DriveTimes()
        {
            InitializeComponent();

            graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            bufferSymbols = new List <FillSymbol>(
                new FillSymbol[] { LayoutRoot.Resources["FillSymbol1"] as FillSymbol,
                                   LayoutRoot.Resources["FillSymbol2"] as FillSymbol,
                                   LayoutRoot.Resources["FillSymbol3"] as FillSymbol });

            _geoprocessorTask = new Geoprocessor("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/GPServer/Generate%20Service%20Areas");
            _geoprocessorTask.JobCompleted           += GeoprocessorTask_JobCompleted;
            _geoprocessorTask.StatusUpdated          += GeoprocessorTask_StatusUpdated;
            _geoprocessorTask.GetResultDataCompleted += GeoprocessorTask_GetResultDataCompleted;
            _geoprocessorTask.Failed += GeoprocessorTask_Failed;
        }
Ejemplo n.º 46
0
        private async void StartDraw()
        {
            if (!IsEnable && MapEditor == null && layer == null)
            {
                return;
            }
            GraphicsLayer drawLayer = layer; // Fix Bug, change layer during drawing
            DrawOptionVm  optionVm  = null;

            foreach (var opt in drawOptions)
            {
                if (opt.IsChecked)
                {
                    optionVm = opt;
                    break;
                }
            }

            if (optionVm != null)
            {
                try
                {
                    var progress = new Progress <GeometryEditStatus>();

                    var result = await MapEditor.RequestShapeAsync(optionVm.Shape, null, progress);

                    var graphic = new Graphic
                    {
                        Geometry = result,
                        Symbol   = optionVm.Symbol
                    };
                    foreach (var item in optionVm.Attributes)
                    {
                        graphic.Attributes.Add(item.Key, item.Value);
                    }
                    drawLayer.Graphics.Add(graphic);
                }
                catch (TaskCanceledException)
                {
                }
                catch (Exception ex)
                {
                    Reset();
                    MessageBox.Show(ex.Message);
                }
            }
        }
        //public GraphicMapPoint TemporarySelectionMapPoint2 { get; set; }
        // public MapPointContent testContent = new MapPointContent(1545454, 2222545);

        /* public MapPointContent TestContent
         * {
         *   get { return testContent; }
         *   set { testContent = value; }
         * }*/
        // private GraphicMapPoint TestPoint = new GraphicMapPoint(1545454, 2222545, 20100);



        public MainWindow()
        {
            //TemporarySelectionMapPoint2 = new GraphicMapPoint(15554, 45454, 102100);
            //TemporarySelectionMapPoint = new GraphicMapPoint(15554, 45454, 102100);
            // License setting and ArcGIS Runtime initialization is done in Application.xaml.cs.
            this.DataContext = this;
            InitializeComponent();
            RuntimeGraphicsLayer = MyMap.Layers["TemporaryGraphicsLayer"] as GraphicsLayer;
            //RuntimeGraphicsLayer.Graphics.Add(new GraphicMapPoint(-7356594.25, 4752385.95, 102100));
            //RuntimeGraphicsLayer.Graphics.Add(new GraphicMapPoint(654893.89, 7718746.02, 102100));
            //RuntimeGraphicsLayer.Graphics.Add(new GraphicMapPoint(4801033.36, 15325547.3, 102100));
            //RuntimeGraphicsLayer.Graphics.Add(new GraphicMapPoint(-5468910.57, 1741081.03, 102100));
            //RuntimeGraphicsLayer.Graphics.Add(new GraphicMapPoint(-5468910.57, 1741081.03, 102100));

            var serviceTest = new com.somee.lukas.LocationBasedTasksService();


            ServiceClient = new LocationBasedTasksServiceClient();
            // Allows us to run an async Task from the non-async constructor
            Task.Run(async() =>
            {
                var request = new FindNearTasksRequest(new FindNearTasksRequestBody()
                {
                    center = new Location(),
                    radius = 9000000,
                    system = Location.MeasurementSystem.Metric
                });

                var result   = await ServiceClient.FindNearTasksAsync(request);
                var list     = result.Body.FindNearTasksResult;
                var listCout = list.Count;
                foreach (var locationTask in list)
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        try
                        {
                            RuntimeGraphicsLayer.Graphics.Add(new GraphicMapPoint(locationTask));
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("error: " + e.Message, "Error");
                        }
                    }));
                }
            });
        }
Ejemplo n.º 48
0
        /// <summary>
        /// Clone Map Layers
        /// </summary>
        private Layer CloneLayer(Layer layer)
        {
            Layer toLayer = null;

            if (layer is GraphicsLayer) // Include FeatureLayer and GeoRSS layers
            {
                GraphicsLayer fromLayer  = layer as GraphicsLayer;
                GraphicsLayer printLayer = new GraphicsLayer();

                printLayer.Renderer  = fromLayer.Renderer;
                printLayer.Clusterer = fromLayer.Clusterer; // todo : clone ?

                GraphicCollection graphicCollection = new GraphicCollection();

                foreach (Graphic graphic in fromLayer.Graphics)
                {
                    Graphic clone = new Graphic();

                    foreach (var kvp in graphic.Attributes)
                    {
                        clone.Attributes.Add(kvp);
                    }

                    clone.Geometry   = graphic.Geometry;
                    clone.Symbol     = graphic.Symbol;
                    clone.Selected   = graphic.Selected;
                    clone.TimeExtent = graphic.TimeExtent;
                    graphicCollection.Add(clone);
                }

                printLayer.Graphics = graphicCollection;

                toLayer                   = printLayer;
                toLayer.ID                = layer.ID;
                toLayer.Opacity           = layer.Opacity;
                toLayer.Visible           = layer.Visible;
                toLayer.MaximumResolution = layer.MaximumResolution;
                toLayer.MinimumResolution = layer.MinimumResolution;
            }
            else
            {
                // Clone other layer types
                toLayer = layer.Clone();
            }

            return(toLayer);
        }
Ejemplo n.º 49
0
        private void OnGetPosInfo(Object sender,OpenReadCompletedEventArgs e)
        {
            if(e.Error!=null)
            {
                MessageBox.Show(e.Error.Message);
                return;
            }
            StreamReader sr=new StreamReader(e.Result);
            string gpsinfo=sr.ReadToEnd();
			if(gpsinfo==null||gpsinfo=="")
				return;
			string[] infoArray = gpsinfo.Split('*');
			if(infoArray.Length < 2)
			{
				return;
			}
			string[] colName = infoArray[0].Split(',');
			string[] row = infoArray[1].Split(',');
            for(int i = 0;i < colName.Length;i++)
            {
                if (colName[i] == "PLon")
                {
                    this.lastPlon = PLon;
                    this.PLon = Convert.ToDouble(row[i]) / 100;
                }
                if (colName[i] == "PLat")
                {
                    this.lastPLat = PLat;
                    this.PLat = Convert.ToDouble(row[i]) / 100;
                }
            }
            context.Post(ShowMarker,null);	
            //绘制轨迹
            if(pathLayer==null)
            {
                pathLayer = new GraphicsLayer();
                this.MapContainer.AddChild(pathLayer);
            }
            if (pathLine == null)
            {
                pathLine = new IMSPolyline(CoordinateType.Logic);
                this.pathLayer.AddGraphics(pathLine);
            }
            pathLine.Points.Add(new Point(this.PLon, this.PLat));
            pathLine.Visibility = this.checkBox3.IsChecked.Value?Visibility.Visible:Visibility.Collapsed;
            this.m_timer.Start();
        }
        public LocationToAddress()
        {
            InitializeComponent();

            ESRI.ArcGIS.Client.Geometry.Envelope initialExtent =
                new ESRI.ArcGIS.Client.Geometry.Envelope(
                    _mercator.FromGeographic(
                        new ESRI.ArcGIS.Client.Geometry.MapPoint(-117.387, 33.97)) as MapPoint,
                    _mercator.FromGeographic(
                        new ESRI.ArcGIS.Client.Geometry.MapPoint(-117.355, 33.988)) as MapPoint);

            initialExtent.SpatialReference = new SpatialReference(102100);

            MyMap.Extent = initialExtent;

            _locationGraphicsLayer = MyMap.Layers["LocationGraphicsLayer"] as GraphicsLayer;
        }
Ejemplo n.º 51
0
        public ServiceAreas()
        {
            InitializeComponent();

            facilitiesGraphicsLayer = MyMap.Layers["MyFacilityGraphicsLayer"] as GraphicsLayer;
            barriersGraphicsLayer   = MyMap.Layers["MyBarrierGraphicsLayer"] as GraphicsLayer;

            myRouteTask = new RouteTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/ServiceArea");
            myRouteTask.SolveServiceAreaCompleted += SolveServiceArea_Completed;
            myRouteTask.Failed += SolveServiceArea_Failed;

            pointBarriers    = new List <Graphic>();
            polylineBarriers = new List <Graphic>();
            polygonBarriers  = new List <Graphic>();

            random = new Random();
        }
        public SDSSpatialQuery()
        {
            InitializeComponent();

            selectionGraphicslayer = MyMap.Layers["MySelectionGraphicsLayer"] as GraphicsLayer;

            MyDrawObject = new Draw(MyMap)
            {
                LineSymbol = LayoutRoot.Resources["DefaultLineSymbol"] as LineSymbol,
                FillSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as FillSymbol
            };
            MyDrawObject.DrawComplete += MyDrawSurface_DrawComplete;

            MyQueryTask = new QueryTask("http://servicesbeta5.esri.com/arcgis/rest/services/UnitedStates/FeatureServer/3");
            MyQueryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
            MyQueryTask.Failed           += QueryTask_Failed;
        }
        private void directionsSegment_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            TextBlock textBlock = sender as TextBlock;
            Graphic   feature   = textBlock.Tag as Graphic;

            MyMap.ZoomTo(Expand(feature.Geometry.Extent));
            if (_activeSegmentGraphic == null)
            {
                _activeSegmentGraphic = new Graphic()
                {
                    Symbol = LayoutRoot.Resources["SegmentSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
                };
                GraphicsLayer graphicsLayer = MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.Graphics.Add(_activeSegmentGraphic);
            }
            _activeSegmentGraphic.Geometry = feature.Geometry;
        }
        public IntersectTaskAsync()
        {
            InitializeComponent();

            _myDrawObject = new Draw(MyMap)
            {
                DrawMode   = DrawMode.Polygon,
                IsEnabled  = false,
                FillSymbol = LayoutRoot.Resources["CyanFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol
            };
            _myDrawObject.DrawComplete += MyDrawObject_DrawComplete;
            _myDrawObject.IsEnabled     = true;

            _intersectGraphicsLayer = MyMap.Layers["IntersectGraphicsLayer"] as GraphicsLayer;

            _geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
        }
        void queryTask_ExecuteCompleted(object sender, QueryEventArgs args)
        {
            FeatureSet featureSet = args.FeatureSet;

            if (featureSet == null || featureSet.Features.Count < 1)
            {
                MessageBox.Show("No features returned from query");
                return;
            }

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            foreach (Graphic graphic in featureSet.Features)
            {
                graphicsLayer.Graphics.Add(graphic);
            }
        }
        void AddMarkerGraphics()
        {
            string jsonCoordinateString         = "{'Coordinates':[{'X':13,'Y':55.59},{'X':72.83,'Y':18.97},{'X':55.43,'Y':34.3}]}";
            CustomCoordinateList coordinateList = DeserializeJson <CustomCoordinateList>(jsonCoordinateString);

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            for (int i = 0; i < coordinateList.Coordinates.Count; i++)
            {
                Graphic graphic = new Graphic()
                {
                    Geometry = mercator.FromGeographic(new MapPoint(coordinateList.Coordinates[i].X, coordinateList.Coordinates[i].Y)),
                    Symbol   = i > 0 ? LayoutRoot.Resources["RedMarkerSymbol"] as Symbol : LayoutRoot.Resources["BlackMarkerSymbol"] as Symbol
                };
                graphicsLayer.Graphics.Add(graphic);
            }
        }
Ejemplo n.º 57
0
        public ExMap(MapView esriMapView)
        {
            _mapView = esriMapView;

            ArcGISTiledMapServiceLayer layer = new ArcGISTiledMapServiceLayer();

            layer.ServiceUri = "http://server.arcgisonline.com/arcgis/rest/services/ESRI_StreetMap_World_2D/MapServer";

            _myLocationLayer        = new GraphicsLayer();
            _redliningGraphicsLayer = new GraphicsLayer();

            _mapView.Map.Layers.Add(layer);
            _mapView.Map.Layers.Add(_redliningGraphicsLayer);
            _mapView.Map.Layers.Add(_myLocationLayer);

            _mapView.ExtentChanged       += _mapView_ExtentChanged;
            _mapView.NavigationCompleted += _mapView_NavigationCompleted;

            //////////Init DrawControl//////////
            //_drawControl = new DrawControl(_mapView);
            //_drawMode = GeoDrawMode.None;
            //_drawControl.SetDrawMode(DrawMode.None);
            //_drawControl.DrawCompletedEvent += _drawControl_DrawCompletedEvent;

            ///////Init default Draw Symbols////////
            PointMarkerSymbol = new SimpleMarkerSymbol();

            PointMarkerSymbol.Color = Colors.Red;
            PointMarkerSymbol.Size  = 15;
            PointMarkerSymbol.Style = SimpleMarkerStyle.Circle;

            PolygonFillSymbol               = new SimpleFillSymbol();
            PolygonFillSymbol.Outline       = new SimpleLineSymbol();
            PolygonFillSymbol.Outline.Color = Colors.Red;
            PolygonFillSymbol.Outline.Width = 3;
            PolygonFillSymbol.Color         = Color.FromArgb(100, 255, 0, 0);

            LineSymbol       = new SimpleLineSymbol();
            LineSymbol.Color = Colors.Red;
            LineSymbol.Width = 5;
            LineSymbol.Style = SimpleLineStyle.Solid;

            TextDrawsymbol      = new TextSymbol();
            TextDrawsymbol.Text = "Text";
            TextDrawsymbol.Font = new SymbolFont("Arial", 15);
        }
Ejemplo n.º 58
0
        void GeometryService_AutoCompleteCompleted(object sender, GraphicsEventArgs e)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["CompletedGraphicsLayer"] as GraphicsLayer;

            graphicsLayer.Graphics.Clear();

            foreach (Graphic g in e.Results)
            {
                g.Symbol = LayoutRoot.Resources["RedFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                graphicsLayer.Graphics.Add(g);
            }

            if (e.Results.Count > 0)
            {
                (MyMap.Layers["ConnectDotsGraphicsLayer"] as GraphicsLayer).Graphics.Clear();
            }
        }
Ejemplo n.º 59
0
        public Union()
        {
            InitializeComponent();

            MyMap.Layers.LayersInitialized += Layers_LayersInitialized;

            MyMap.MinimumResolution = double.Epsilon;

            MyDrawObject = new Draw(MyMap)
            {
                DrawMode  = DrawMode.Point,
                IsEnabled = false,
            };
            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;

            parcelGraphicsLayer = MyMap.Layers["ParcelsGraphicsLayer"] as GraphicsLayer;
        }
Ejemplo n.º 60
0
        /// <summary>
        /// Copy the elements to an offset location
        /// </summary>
        /// <param name="graphicsLayer"></param>
        /// <param name="elements"></param>
        internal static void CustomCopyElements(this GraphicsLayer graphicsLayer, IEnumerable <Element> elements)
        {
            if (elements.Count() == 0)
            {
                return;
            }
            //Copy the elements.
            var copyElements = graphicsLayer.CopyElements(elements);

            //Iterate through the elements to move the anchor point for the copy.
            foreach (var element in copyElements)
            {
                var elementPoly = PolygonBuilder.CreatePolygon(element.GetBounds());
                var pointsList  = elementPoly.Copy2DCoordinatesToList();
                element.SetAnchorPoint(pointsList[1]);
            }
        }