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;
 }
        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 LineLength()
        {
            InitializeComponent();

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

            _graphicsLayer = mapView.Map.Layers["GraphicsLayer"] as GraphicsLayer;
            var task = SetupSymbols();
        }
Example #6
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;
        }
Example #7
0
 public void Start()
 {
     if (explosionLayer != null) return;
     explosionLayer = new GraphicsLayer { ID = Id };
     explosionLayer.Initialize();
     ((dsBaseLayer)Layer).ChildLayers.Insert(0, explosionLayer);
 }
        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;
        }
        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);
        }
Example #10
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);
 }
        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;
            }
        }
        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;
        }
            /// <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);
                    });
                }
            }
Example #14
0
 public void Start()
 {
     if (ZonesLayer != null) return;
     ZonesLayer = new GraphicsLayer { ID = Id };
     ZonesLayer.Initialize();
     ((dsBaseLayer)Layer).ChildLayers.Insert(0, ZonesLayer);
 }
		/// <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;
        }
        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;
        }
        public GraphicsSourceSample()
        {
            this.InitializeComponent();

            _graphicsLayer = MyMapView.Map.Layers["GraphicsLayer"] as GraphicsLayer;
            CreateGraphics();
        }
        /// <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();
        }
        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();
        }
		/// <summary>Construct Graphics Source sample control</summary>
		public GraphicsSourceSample()
		{
			InitializeComponent();

			_graphicsLayer = MyMapView.Map.Layers["graphicsLayer"] as GraphicsLayer;
			MyMapView.NavigationCompleted += MyMapView_NavigationCompleted;
		}
        /// <summary>Construct Graphics Hit Testing sample control</summary>
        public GraphicsHitTesting()
        {
            InitializeComponent();

			_graphicsLayer = MyMapView.Map.Layers["graphicsLayer"] as GraphicsLayer;
			MyMapView.ExtentChanged += MyMapView_ExtentChanged;
        }
Example #23
0
 public void Start()
 {
     if (circleLayer != null) return;
     circleLayer = new GraphicsLayer { ID = Id, IsHitTestVisible = false };
     circleLayer.Initialize();
     ((dsBaseLayer)Layer).ChildLayers.Insert(0, circleLayer);
 }
        public Routing()
        {
            InitializeComponent();

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

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

            mapView.ExtentChanged += mapView_ExtentChanged;
        }
		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;
		}
Example #29
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);
 }
        /// <summary>Construct Class Breaks Renderer sample control</summary>
        public ClassBreaksRendererSample()
        {
            InitializeComponent();

            _earthquakes = mapView.Map.Layers["Earthquakes"] as GraphicsLayer;
                
            mapView.ExtentChanged += mapView_ExtentChanged;
        }