예제 #1
0
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            CsvLayer csvLayer = MyMap.Layers["MyCSVLayer"] as CsvLayer;

            System.Windows.Point screenPnt = MyMap.MapToScreen(e.MapPoint);

            // Account for difference between Map and application origin
            GeneralTransform generalTransform = MyMap.TransformToVisual(null);

            System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt);

            int  tolerance  = 20;
            Rect screenRect = new Rect(new Point(transformScreenPnt.X - tolerance / 2, transformScreenPnt.Y - tolerance / 2),
                                       new Point(transformScreenPnt.X + tolerance / 2, transformScreenPnt.Y + tolerance / 2));
            IEnumerable <Graphic> selected =
                csvLayer.FindGraphicsInHostCoordinates(screenRect);

            foreach (Graphic g in selected)
            {
                MyInfoWindow.Anchor = e.MapPoint;
                MyInfoWindow.IsOpen = true;
                //Since a ContentTemplate is defined, Content will define the DataContext for the ContentTemplate
                MyInfoWindow.Content = g.Attributes;
                return;
            }
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            MapPoint geographicPoint = _mercator.ToGeographic(e.MapPoint) as MapPoint;

            string SOEurl = "http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/Elevation/ESRI_Elevation_World/MapServer/exts/ElevationsSOE/ElevationLayers/1/GetElevationAtLonLat";

            SOEurl += string.Format(System.Globalization.CultureInfo.InvariantCulture, "?lon={0}&lat={1}&f=json", geographicPoint.X, geographicPoint.Y);

            WebClient webClient = new WebClient();

            webClient.OpenReadCompleted += (s, a) =>
            {
                var    sr  = new StreamReader(a.Result);
                string str = sr.ReadToEnd();


                JObject jsonResponse = JObject.Parse(str);
                double  elevation    = (double)jsonResponse["elevation"];
                a.Result.Close();

                MyInfoWindow.Anchor  = e.MapPoint;
                MyInfoWindow.Content = string.Format("Elevation: {0} meters", elevation.ToString("0"));
                MyInfoWindow.IsOpen  = true;
            };

            webClient.OpenReadAsync(new Uri(SOEurl));
        }
        /// <summary>
        /// Mouse handler that sets the coordinates of the clicked point into text in the toolbar.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            try
            {
                client.Geometry.MapPoint clickPoint = e.MapPoint;
                if (_graphicsLayer == null)
                {
                    _graphicsLayer    = new ESRI.ArcGIS.Client.GraphicsLayer();
                    _graphicsLayer.ID = "FarthestOnCircleGraphics";
                    client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                    if (aclyrs.Count() > 0)
                    {
                        aclyrs.ChildLayers.Add(_graphicsLayer);
                    }
                }
                ResourceDictionary mydictionary = new ResourceDictionary();
                mydictionary.Source = new Uri("/FarthestOnCircleAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
                client.Graphic graphic = new client.Graphic();
                graphic.Geometry = clickPoint;
                graphic.Symbol   = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
                _graphicsLayer.Graphics.Add(graphic);

                RunButton.IsEnabled = true;
                if (_mapWidget != null)
                {
                    _mapWidget.Map.MouseClick -= Map_MouseClick;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            _geoprocessorTask.CancelAsync();

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

            graphicsLayer.ClearGraphics();

            Graphic graphic = new Graphic()
            {
                Symbol   = LayoutRoot.Resources["DefaultMarkerSymbol"] as Symbol,
                Geometry = e.MapPoint,
            };

            graphic.Attributes.Add("Info", "Start location");
            string latlon = String.Format("{0}, {1}", e.MapPoint.X, e.MapPoint.Y);

            graphic.Attributes.Add("LatLon", latlon);
            graphic.SetZIndex(1);
            graphicsLayer.Graphics.Add(graphic);

            List <GPParameter> parameters = new List <GPParameter>();

            parameters.Add(new GPFeatureRecordSetLayer("Input_Location", e.MapPoint));
            parameters.Add(new GPString("Drive_Times", "1 2 3"));

            _geoprocessorTask.ExecuteAsync(parameters);
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            FeatureLayer featureLayer = MyMap.Layers["MyFeatureLayer"] as FeatureLayer;

            System.Windows.Point screenPnt = MyMap.MapToScreen(e.MapPoint);

            // Account for difference between Map and application origin
            GeneralTransform generalTransform = MyMap.TransformToVisual(Application.Current.MainWindow);

            System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt);

            IEnumerable <Graphic> selected =
                featureLayer.FindGraphicsInHostCoordinates(transformScreenPnt);

            foreach (Graphic g in selected)
            {
                MyInfoWindow.Anchor = e.MapPoint;
                MyInfoWindow.IsOpen = true;
                //Since a ContentTemplate is defined, Content will define the DataContext for the ContentTemplate
                MyInfoWindow.Content = g.Attributes;
                return;
            }

            InfoWindow window = new InfoWindow()
            {
                Anchor          = e.MapPoint,
                Map             = MyMap,
                IsOpen          = true,
                ContentTemplate = LayoutRoot.Resources["LocationInfoWindowTemplate"] as System.Windows.DataTemplate,
                //Since a ContentTemplate is defined, Content will define the DataContext for the ContentTemplate
                Content = e.MapPoint
            };

            LayoutRoot.Children.Add(window);
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            _geometryService.CancelAsync();
            _queryTask.CancelAsync();

            Graphic clickGraphic = new Graphic();

            clickGraphic.Symbol   = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = e.MapPoint;
            // Input spatial reference for buffer operation defined by first feature of input geometry array
            clickGraphic.Geometry.SpatialReference = MyMap.SpatialReference;

            _pointAndBufferGraphicsLayer.ClearGraphics();
            _resultsGraphicsLayer.ClearGraphics();

            clickGraphic.SetZIndex(2);
            _pointAndBufferGraphicsLayer.Graphics.Add(clickGraphic);

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
                BufferSpatialReference = new SpatialReference(4326),
                OutSpatialReference    = MyMap.SpatialReference,
                Unit = LinearUnit.Meter,
            };
            bufferParams.Distances.Add(100);
            bufferParams.Features.Add(clickGraphic);

            _geometryService.BufferAsync(bufferParams);
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            _geoprocessorTask.CancelAsync();

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

            graphicsLayer.ClearGraphics();

            MapPoint mapPoint = e.MapPoint;

            mapPoint.SpatialReference = new SpatialReference(4326);

            Graphic graphic = new Graphic()
            {
                Symbol   = LayoutRoot.Resources["StartMarkerSymbol"] as Symbol,
                Geometry = mapPoint
            };

            graphicsLayer.Graphics.Add(graphic);

            MyMap.Cursor = System.Windows.Input.Cursors.Wait;

            List <GPParameter> parameters = new List <GPParameter>();

            parameters.Add(new GPFeatureRecordSetLayer("Input_Observation_Point", mapPoint));
            parameters.Add(new GPLinearUnit("Viewshed_Distance", esriUnits.esriMiles, Convert.ToDouble(MilesTextBox.Text)));

            _geoprocessorTask.OutputSpatialReference = new SpatialReference(4326);
            _geoprocessorTask.ExecuteAsync(parameters);
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            graphicsLayer.ClearGraphics();

            e.MapPoint.SpatialReference = MyMap.SpatialReference;
            Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = e.MapPoint,
                Symbol   = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };

            graphic.SetZIndex(1);
            graphicsLayer.Graphics.Add(graphic);

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

            geometryService.BufferCompleted += GeometryService_BufferCompleted;
            geometryService.Failed          += GeometryService_Failed;

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            BufferParameters bufferParams = new BufferParameters()
            {
                Unit = LinearUnit.StatuteMile,
                BufferSpatialReference = new SpatialReference(4326),
                OutSpatialReference    = MyMap.SpatialReference
            };

            bufferParams.Features.Add(graphic);
            bufferParams.Distances.Add(5);

            geometryService.BufferAsync(bufferParams);
        }
예제 #9
0
 private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
 {
     if (StopsRadioButton.IsChecked.Value)
     {
         Graphic stop = new Graphic()
         {
             Geometry = e.MapPoint, Symbol = LayoutRoot.Resources["StopSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
         };
         stop.Attributes.Add("StopNumber", stopsLayer.Graphics.Count + 1);
         stopsLayer.Graphics.Add(stop);
         _stops.Add(stop);
     }
     else if (BarriersRadioButton.IsChecked.Value)
     {
         Graphic barrier = new Graphic()
         {
             Geometry = e.MapPoint, Symbol = LayoutRoot.Resources["BarrierSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
         };
         barriersLayer.Graphics.Add(barrier);
         _barriers.Add(barrier);
     }
     if (_stops.Count > 1)
     {
         if (_routeTask.IsBusy)
         {
             _routeTask.CancelAsync();
         }
         _routeParams.OutSpatialReference = MyMap.SpatialReference;
         _routeTask.SolveAsync(_routeParams);
     }
 }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            MapPoint geographicPoint = _mercator.ToGeographic(e.MapPoint) as MapPoint;

            string SOEurl = "http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/Elevation/ESRI_Elevation_World/MapServer/exts/ElevationsSOE/ElevationLayers/1/GetElevationAtLonLat";

            SOEurl += string.Format(System.Globalization.CultureInfo.InvariantCulture, "?lon={0}&lat={1}&f=json", geographicPoint.X, geographicPoint.Y);

            WebClient webClient = new WebClient();

            webClient.OpenReadCompleted += (s, a) =>
            {
                StreamReader reader                  = new StreamReader(a.Result);
                string       responseString          = reader.ReadToEnd();
                IDictionary <string, object> results =
                    serializer.DeserializeObject(responseString) as IDictionary <string, object>;

                if (results != null && results.ContainsKey("elevation"))
                {
                    double elevation = Math.Round(Convert.ToDouble(results["elevation"]), 0);
                    a.Result.Close();
                    MyInfoWindow.Anchor  = e.MapPoint;
                    MyInfoWindow.Content = string.Format("Elevation: {0} meters", elevation.ToString());
                    MyInfoWindow.IsOpen  = true;
                }
            };

            webClient.OpenReadAsync(new Uri(SOEurl));
        }
        private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
                Geometry         = clickPoint,
                MapExtent        = MyMap.Extent,
                Width            = (int)MyMap.ActualWidth,
                Height           = (int)MyMap.ActualHeight,
                LayerOption      = LayerOption.visible,
                SpatialReference = MyMap.SpatialReference
            };

            IdentifyTask identifyTask = new IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
                                                         "Demographics/ESRI_Census_USA/MapServer");

            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed           += IdentifyTask_Failed;
            identifyTask.ExecuteAsync(identifyParams);

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

            graphicsLayer.Graphics.Clear();
            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = clickPoint,
                Symbol   = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphicsLayer.Graphics.Add(graphic);
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            System.Windows.Point screenPnt = MyMap.MapToScreen(e.MapPoint);
            // Account for difference between Map and application origin
            GeneralTransform generalTransform = MyMap.TransformToVisual(Application.Current.MainWindow);

            System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt);
            var selected = new List <Graphic>();

            selected.AddRange(RuntimeGraphicsLayer.FindGraphicsInHostCoordinates(transformScreenPnt));

            //if button was pressen on clear map point
            if (selected.Count == 0)
            {
                ClearSelection();
                CreateNewSelectionMapPoint();
                return;
            }

            // if button was pressen on item (which is on map)
            else
            {
                ClearSelection();
                foreach (Graphic g in selected)
                {
                    SelectedExistingItem           = g as GraphicMapPoint;
                    SelectedPointInfoWindow.Anchor = new MapPoint(g.Geometry.Extent.XMax, g.Geometry.Extent.YMax, g.Geometry.SpatialReference);
                    SelectedPointInfoWindow.IsOpen = true;
                    //Since a ContentTemplate is defined, Content will define the DataContext for the ContentTemplate
                    //SelectedPointInfoWindow.Content = g.Attributes;
                    return;
                }
            }
        }
예제 #13
0
 /// <summary>
 /// Mouse handler that sets the coordinates of the clicked point into text in the toolbar.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
 {
     try
     {
         client.Geometry.MapPoint clickPoint = e.MapPoint;
         WebMercator mercator        = new ESRI.ArcGIS.Client.Projection.WebMercator();
         client.Geometry.MapPoint pt = null;
         pt = mercator.ToGeographic(clickPoint) as client.Geometry.MapPoint;
         if (_graphicsLayer == null)
         {
             _graphicsLayer    = new client.GraphicsLayer();
             _graphicsLayer.ID = "ComputedPoints";
             client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
             if (aclyrs.Count() > 0)
             {
                 aclyrs.ChildLayers.Add(_graphicsLayer);
             }
         }
         ResourceDictionary mydictionary = new ResourceDictionary();
         mydictionary.Source = new Uri("/AirCraftRouteGenerationLineAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
         client.Graphic graphic = new client.Graphic();
         graphic.Geometry = pt;
         graphic.Symbol   = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
         _graphicsLayer.Graphics.Add(graphic);
         RunButton.IsEnabled = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in map mouseclick: " + ex.Message);
     }
 }
예제 #14
0
        /// <summary>
        /// Mouse handler that sets the coordinates of the clicked point into text in the toolbar.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            client.Geometry.MapPoint clickPoint = e.MapPoint;
            //WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();
            ///client.Geometry.MapPoint pt = null;
            //pt = mercator.ToGeographic(clickPoint) as client.Geometry.MapPoint;
            if (_graphicsLayer == null)
            {
                _graphicsLayer = new client.GraphicsLayer();

                _graphicsLayer.ID = "AircraftCommunicationGraphics";
                client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                if (aclyrs.Count() > 0)
                {
                    aclyrs.ChildLayers.Add(_graphicsLayer);
                }
            }
            ResourceDictionary mydictionary = new ResourceDictionary();

            mydictionary.Source = new Uri("/AircraftCommunicationCoverageAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
            client.Graphic graphic = new client.Graphic();
            //graphic.Geometry = pt;
            graphic.Geometry = clickPoint;
            graphic.Symbol   = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
            _graphicsLayer.Graphics.Add(graphic);

            if (_graphicsLayer != null && _graphicsLayerPoly != null)
            {
                if (_graphicsLayer.Graphics.Count() > 0 && _graphicsLayerPoly.Graphics.Count() > 0)
                {
                    RunButton.IsEnabled = true;
                }
            }
        }
예제 #15
0
        /// <summary>
        /// Mouse handler that sets the coordinates of the clicked point into text in the toolbar.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            try
            {
                if (_mapWidget != null)
                {
                    _mapWidget.Map.MouseClick -= Map_MouseClick;
                }
                // Find the map layer in the map widget that contains the data source.
                IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources;
                foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources)
                {
                    if (_mapWidget != null && d.IsSelectable == true)
                    {
                        // Get the feature layer in the map for the data source.
                        client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d);

                        //Clear Selection on Feature Layers in map
                        featureL.ClearSelection();
                    }
                }
                location = e.MapPoint;
                if (_graphicsLayer == null)
                {
                    _graphicsLayer    = new ESRI.ArcGIS.Client.GraphicsLayer();
                    _graphicsLayer.ID = "BombThreatGraphics";
                    client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                    if (aclyrs.Count() > 0)
                    {
                        aclyrs.ChildLayers.Add(_graphicsLayer);
                    }
                }

                _graphicsLayer.ClearGraphics();
                Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                graphic.Geometry = location;
                graphic.Attributes.Add("Evac", bombType.Text);
                ResourceDictionary mydictionary = new ResourceDictionary();
                mydictionary.Source = new Uri("/BombThreatAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);

                graphic.Symbol        = mydictionary["DefaultClickSymbol"] as client.Symbols.MarkerSymbol;
                _graphicsLayer.MapTip = new ContentControl()
                {
                    ContentTemplate = (DataTemplate)Resources["kymaptip"]
                };
                _graphicsLayer.MapTip.SetBinding(ContentControl.ContentProperty, new Binding());
                graphic.SetZIndex(1);
                _graphicsLayer.Graphics.Add(graphic);

                if (location != null)
                {
                    RunButton.IsEnabled = true;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error in mouseclick: " + ex.Message);
            }
        }
예제 #16
0
        private void MapPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            ParcelLineInfoWindow.IsOpen = false;

            if (DPE_ParcelEntry.IsExpanded || (!PDE_Tools.IsExpanded && !PDE_Find.IsExpanded && !PDE_Share.IsExpanded))
            {
                ParcelTool(e.MapPoint);
            }
            else if (PDE_Tools.IsExpanded)
            {
                if (_originPoint == null)
                {
                    ParcelTool(e.MapPoint);
                }

                // Sometimes we don't get the mouse up event? Ensure its released now.
                _srPoint = null;
            }
            else if (PDE_Find.IsExpanded)
            {
                bool create = _identifyDialog == null || !_identifyDialog.IsLoaded;
                if (create)
                {
                    _identifyDialog = new IdentifyWindow();
                }
                double dialogWidth  = _identifyDialog.Width;  // If dialog is new, capture size
                double dialogHeight = _identifyDialog.Height; // before its shown.
                if (create)
                {
                    _identifyDialog.Owner = this;
                    _identifyDialog.Show();
                }
                _identifyDialog.Visibility = System.Windows.Visibility.Hidden;
                _identifyDialog.IdentifyPoint(ParcelMap, ref _xmlConfiguation, e.MapPoint);

                int    offset = 10; // Hard coded offset so we don't position the window exactly where the cursor is
                double top    = e.ScreenPoint.Y + this.Top +
                                SystemParameters.ResizeFrameVerticalBorderWidth +
                                SystemParameters.CaptionHeight + offset;
                double left = e.ScreenPoint.X + this.Left +
                              SystemParameters.ResizeFrameVerticalBorderWidth + offset;

                // Keep the window in the virtual screen bounds
                double screenWidth  = System.Windows.SystemParameters.VirtualScreenWidth;
                double screenHeight = System.Windows.SystemParameters.VirtualScreenHeight;
                if (left + dialogWidth > screenWidth)
                {
                    left = screenWidth - dialogWidth;
                }
                if (top + dialogHeight > screenHeight)
                {
                    top = screenHeight - dialogHeight;
                }

                _identifyDialog.Top  = top;
                _identifyDialog.Left = left;
            }
        }
예제 #17
0
 private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
 {
     //Submit a new job only when the previous is completed
     if (jobid == null)
     {
         inputPoint = null;
         SubmitJob(e.MapPoint);
     }
 }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            Locator locatorTask = new Locator("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer");

            locatorTask.LocationToAddressCompleted += LocatorTask_LocationToAddressCompleted;
            locatorTask.Failed += LocatorTask_Failed;

            // Tolerance (distance) specified in meters
            double tolerance = 30;

            locatorTask.LocationToAddressAsync(e.MapPoint, tolerance, e.MapPoint);
        }
예제 #19
0
        private void ReLoadMe(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            Envelope env;

            env      = new Envelope();
            env.XMin = 122.06;
            env.YMin = 30.02;
            env.XMax = 122.08;
            env.YMax = 30.04;
            mainmap.Layers["zsstreetmap16"].Visible = false;
            mainmap.Extent = env; //  "121.995787,29.932494,122.256907,30.245483";
            mainmap.Layers["zsstreetmap16"].Visible = true;
        }
예제 #20
0
 private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
 {
     if (jobid != null)
     {
         inputPoint = e.MapPoint;
         _geoprocessorTask.CancelJobAsync(jobid);
     }
     else
     {
         inputPoint = null;
         SubmitJob(e.MapPoint);
     }
 }
 private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
 {
     try
     {
         ArcGISImageServiceLayer imageLayer = MyMap.Layers["ImageServiceLayer"] as ArcGISImageServiceLayer;
         MosaicRule mosaicRule = new MosaicRule();
         mosaicRule.MosaicMethod = "esriMosaicViewpoint";
         mosaicRule.Viewpoint    = e.MapPoint;
         imageLayer.MosaicRule   = mosaicRule;
         imageLayer.Refresh();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #22
0
        void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            graphicsLayer.Graphics.Clear();
            SelectedWellsTreeView.ItemsSource = null;
            RelatedRowsDataGrid.ItemsSource   = null;

            Query query = new Query()
            {
                Geometry            = Expand(MyMap.Extent, e.MapPoint, 0.01),
                ReturnGeometry      = true,
                OutSpatialReference = MyMap.SpatialReference
            };

            query.OutFields.Add("*");

            queryTask.ExecuteAsync(query);
        }
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            client.Geometry.MapPoint clickPoint = e.MapPoint;

            if (clickPoint != null)
            {
                e.MapPoint.SpatialReference = _mapWidget.Map.SpatialReference;
                client.Graphic graphic = new client.Graphic()
                {
                    Geometry = e.MapPoint,
                    Symbol   = _resourceDictionary["bufferSymbol"] as client.Symbols.PictureMarkerSymbol
                };

                graphic.SetZIndex(1);
                _bufferPointLayer.Graphics.Add(graphic);
            }
        }
 // ***********************************************************************************
 // * Add an incident location on the map... closest facility will be found for this location
 // ***********************************************************************************
 void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
 {
     client.Geometry.MapPoint clickPoint = e.MapPoint;
     if (clickPoint != null)
     {
         client.Graphic tempGraphic = new client.Graphic()
         {
             Geometry = clickPoint,
             Symbol   = new client.Symbols.SimpleMarkerSymbol()
             {
                 Color = System.Windows.Media.Brushes.Red,
                 Size  = 12,
                 Style = client.Symbols.SimpleMarkerSymbol.SimpleMarkerStyle.Circle
             }
         };
         _incidentsGraphicsLayer.Graphics.Add(tempGraphic);
     }
 }
예제 #25
0
        // ***********************************************************************************
        // * ...Let user enter the incident location on the map
        // ***********************************************************************************
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            try
            {
                _spillLocationGraphicsLayer.ClearGraphics();
                client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                graphic.Geometry = e.MapPoint;

                graphic.Symbol = _mydictionary["spillSymbol"] as client.Symbols.MarkerSymbol;
                graphic.SetZIndex(1);
                _spillLocationGraphicsLayer.Graphics.Add(graphic);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error in mouseclick: " + ex.Message);
            }
            _mapWidget.Map.MouseClick -= Map_MouseClick;
        }
예제 #26
0
        private async void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            try
            {
                if (_cts != null)
                {
                    _cts.Cancel();
                }

                _cts = new CancellationTokenSource();

                Graphic stop = new Graphic()
                {
                    Geometry = e.MapPoint
                };

                _stopsGraphicsLayer.Graphics.Add(stop);

                if (_stopsGraphicsLayer.Graphics.Count > 1)
                {
                    if (_routeTask.IsBusy)
                    {
                        _cts.Cancel();
                        _stopsGraphicsLayer.Graphics.RemoveAt(_stopsGraphicsLayer.Graphics.Count - 1);
                    }

                    SolveRouteResult result = await _routeTask.SolveTaskAsync(_routeParams, _cts.Token);

                    _routeGraphicsLayer.Graphics.Clear();
                    _routeGraphicsLayer.Graphics.Add(result.RouteResults[0].Route);
                }
            }
            catch (Exception ex)
            {
                _stopsGraphicsLayer.Graphics.RemoveAt(_stopsGraphicsLayer.Graphics.Count - 1);

                if (ex is ServiceException)
                {
                    MessageBox.Show(String.Format("{0}: {1}", (ex as ServiceException).Code.ToString(), (ex as ServiceException).Details[0]), "Error", MessageBoxButton.OK);
                    return;
                }
            }
        }
예제 #27
0
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            Locator locatorTask = new Locator("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer");

            locatorTask.LocationToAddressCompleted += LocatorTask_LocationToAddressCompleted;
            locatorTask.Failed += LocationToAddressLocatorTask_Failed;
            Dictionary <string, string> address = new Dictionary <string, string>();

            address.Add("forStorage", "true");
            address.Add("token", "pgPwo32cfo-kLf0ABYjV9RZjxGNfFB4--xSkGLOY4bUx0UhmFMc0-06KJCPtx4uRsIGuO_9xn_cxI2G2w9IoD3hX7Q-LGulIg2VhKUcvklXu7CblMg1--yg5kznhXjSF");

            locatorTask.CustomParameters = address;


            // Tolerance (distance) specified in meters
            double tolerance = 30;

            locatorTask.LocationToAddressAsync(e.MapPoint, tolerance, e.MapPoint);
        }
예제 #28
0
        //Add a map point (from mouse click) to the geometry of the sketch
        //Create a temporary graphic to trace user's mouse movement
        void map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            sketchGeometry.Paths[0].Add(e.MapPoint);


            //feedback layer
            feedBackLyr.Graphics.Clear();

            client.Map map = MapWidget.Map;

            #region Create a temporary graphic to trace user's mouse movement
            //Create a point collection using the last clicked point and the latest mouse position
            PointCollection pc = new PointCollection();
            pc.Add(sketchGeometry.Paths[0].Last());
            pc.Add(new MapPoint());

            //Create the geometry of the feedback line using the point collection
            client.Geometry.Polyline feedbackGeomrtry = new client.Geometry.Polyline();
            feedbackGeomrtry.SpatialReference = map.SpatialReference;
            feedbackGeomrtry.Paths.Add(pc);

            //Create the feedback line with the geometry and a symbol
            client.Graphic feedback = new client.Graphic()
            {
                Symbol   = SimplePolylineSymbol.CreateLineSymbol(),
                Geometry = feedbackGeomrtry,
            };
            #endregion

            //Add the feedback line to the feedback layer
            feedBackLyr.Graphics.Add(feedback);

            //Add the layer to the map if we haevn't done so
            if (!map.Layers.Contains(feedBackLyr))
            {
                map.Layers.Add(feedBackLyr);
            }
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            Graphic graphic = new Graphic()
            {
                Symbol   = LayoutRoot.Resources["StartMarkerSymbol"] as Symbol,
                Geometry = e.MapPoint
            };

            _graphicsLayer.Graphics.Add(graphic);

            Geoprocessor geoprocessorTask = new Geoprocessor("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_Currents_World/GPServer/MessageInABottle");

            geoprocessorTask.ExecuteCompleted      += GeoprocessorTask_ExecuteCompleted;
            geoprocessorTask.Failed                += GeoprocessorTask_Failed;
            geoprocessorTask.OutputSpatialReference = MyMap.SpatialReference;

            List <GPParameter> parameters = new List <GPParameter>();

            parameters.Add(new GPFeatureRecordSetLayer("Input_Point", _mercator.ToGeographic(e.MapPoint)));
            parameters.Add(new GPDouble("Days", Convert.ToDouble(DaysTextBox.Text)));

            geoprocessorTask.ExecuteAsync(parameters);
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            MapPoint geographicPoint = _mercator.ToGeographic(e.MapPoint) as MapPoint;

            string SOEurl = "http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/Elevation/ESRI_Elevation_World/MapServer/exts/ElevationsSOE/ElevationLayers/1/GetElevationAtLonLat";

            SOEurl += string.Format(System.Globalization.CultureInfo.InvariantCulture, "?lon={0}&lat={1}&f=json", geographicPoint.X, geographicPoint.Y);

            WebClient webClient = new WebClient();

            webClient.OpenReadCompleted += (s, a) =>
            {
                DataContractJsonSerializer serializer         = new DataContractJsonSerializer(typeof(ElevationSOELatLon));
                ElevationSOELatLon         elevationSOELatLon = serializer.ReadObject(a.Result) as ElevationSOELatLon;
                a.Result.Close();

                MyInfoWindow.Anchor  = e.MapPoint;
                MyInfoWindow.Content = string.Format("Elevation: {0} meters", elevationSOELatLon.Elevation.ToString("0"));
                MyInfoWindow.IsOpen  = true;
            };

            webClient.OpenReadAsync(new Uri(SOEurl));
        }