void map_Gesture(object sender, Map.MapGestureEventArgs e)
 {
     if (e.Gesture == GestureType.Tap || e.Gesture == GestureType.Hold)
     {
         doNotShowResults     = false;
         identifyTaskResults  = null;
         clickPoint           = e.MapPoint;
         waitedForDoubleClick = false;
         initiatedByTouch     = true;
         DoIdentify();
     }
 }
Exemple #2
0
 private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
 {
     if (e.Gesture == GestureType.Tap && MyMap.Extent != null && !_dispatcherTimer.IsEnabled)
     {
         _currentScreenPoint = e.GetPosition(MyMap);
         _dispatcherTimer.Start();
     }
     else if (e.Gesture == GestureType.DoubleTap)
     {
         _dispatcherTimer.Stop();
     }
 }
        private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
        {
            if (e.Gesture == GestureType.Tap)
            {
                MyInfoWindow.IsOpen = false;

                GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
                IEnumerable<Graphic> selected = e.DirectlyOver(10, new GraphicsLayer[] { graphicsLayer });
                foreach (Graphic g in selected)
                {
                    MyInfoWindow.Anchor = e.MapPoint;
                    MyInfoWindow.IsOpen = true;
                    MyInfoWindow.DataContext = g;
                    return;
                }
            }
        }
        private void Map_MapGesture(object sender, Map.MapGestureEventArgs e)
        {
            if (!displayAttribute || editor == null || !editor.GraphicsLayers.Any(l => l is FeatureLayer))
            {
                return;
            }
            if (e.Gesture != GestureType.Tap)
            {
                return;
            }
            var featureLayers = from l in editor.GraphicsLayers
                                where l is FeatureLayer
                                select l as FeatureLayer;
            var graphics = e.DirectlyOver(TAP_TOLERANCE, featureLayers);

            if (graphics != null && graphics.GetEnumerator().MoveNext())
            {
                var          graphic = graphics.First();
                FeatureLayer layer   = null;
                if (graphic == null)
                {
                    return;
                }
                foreach (var l in featureLayers)
                {
                    if (l.Graphics == null)
                    {
                        return;
                    }
                    if (l.Graphics.Contains(graphic))
                    {
                        layer = l;
                        break;
                    }
                }
                if (layer != null)
                {
                    e.Handled = true;
                    TemplatePicker.ShowAttributeForm(layer, graphic);
                    this.displayAttribute = this.Continuous;
                }
            }
        }
Exemple #5
0
 private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
 {
     if (e.Gesture == GestureType.Hold)
     {
         FeatureLayer          featureLayer = MyMap.Layers["SaveTheBayMarineLayer"] as FeatureLayer;
         IEnumerable <Graphic> selected     = e.DirectlyOver(10, new GraphicsLayer[] { featureLayer });
         foreach (Graphic g in selected)
         {
             InfoWindow.Anchor  = e.MapPoint;
             InfoWindow.IsOpen  = true;
             InfoWindow.Content = g;
             return;
         }
     }
     else
     {
         InfoWindow.IsOpen = false;
     }
 }
        private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
        {
            if (e.Gesture == GestureType.Tap &&
                !facilitiesEditor.CancelActive.CanExecute(null) &&
                !incidentsEditor.CancelActive.CanExecute(null) &&
                !barriersEditor.CancelActive.CanExecute(null))
            {
                MyRouteInfoWindow.IsOpen = false;

                GraphicsLayer         graphicsLayer = MyMap.Layers["MyRoutesGraphicsLayer"] as GraphicsLayer;
                IEnumerable <Graphic> selected      = e.DirectlyOver(10, new GraphicsLayer[] { graphicsLayer });
                foreach (Graphic g in selected)
                {
                    MyRouteInfoWindow.Anchor      = e.MapPoint;
                    MyRouteInfoWindow.IsOpen      = true;
                    MyRouteInfoWindow.DataContext = g;
                    return;
                }
            }
        }
Exemple #7
0
        private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
        {
            if (e.Gesture == GestureType.Tap && MyMap.Extent != null)
            {
                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);

                Graphic graphic = new Graphic()
                {
                    Symbol   = DefaultMarkerSymbol,
                    Geometry = e.MapPoint
                };
                GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.Graphics.Clear();
                graphicsLayer.Graphics.Add(graphic);
            }
        }
        private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + e.Gesture.ToString());

            if (e.Gesture == GestureType.Tap || e.Gesture == GestureType.Hold)
            {
                List <Graphic> results = new List <Graphic>(e.DirectlyOver(10));
                if (results.Count == 0)
                {
                    MyInfoWindow.IsOpen = false;
                }
                else
                {
                    _tapGraphic = results[0];
                    _dispatcherTimer.Start();
                }
            }
            else if (e.Gesture == GestureType.DoubleTap)
            {
                _dispatcherTimer.Stop();
            }
        }
        private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
        {
            MapPoint mapPoint = e.MapPoint;

            if (_displayViewshedInfo && resultLayer != null && e.Gesture == GestureType.Tap)
            {
                ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
                {
                    Geometry         = mapPoint,
                    MapExtent        = MyMap.Extent,
                    Width            = (int)MyMap.ActualWidth,
                    Height           = (int)MyMap.ActualHeight,
                    LayerOption      = LayerOption.visible,
                    SpatialReference = MyMap.SpatialReference
                };

                IdentifyTask identifyTask = new IdentifyTask(resultLayer.Url);
                identifyTask.ExecuteCompleted += (s, ie) =>
                {
                    if (ie.IdentifyResults.Count > 0)
                    {
                        foreach (var identifyresult in ie.IdentifyResults)
                        {
                            if (identifyresult.LayerId == 1)
                            {
                                Graphic g = identifyresult.Feature;
                                MyInfoWindow.Anchor  = e.MapPoint;
                                MyInfoWindow.Content = g.Attributes;
                                MyInfoWindow.IsOpen  = true;
                                break;
                            }
                        }
                    }
                };
                identifyTask.ExecuteAsync(identifyParams);
            }
        }
Exemple #10
0
        private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
        {
            if (isAdd)
            {
                return;
            }

            // open the feature dialog on tap of a feature
            if (e.Gesture == GestureType.Tap)
            {
                IEnumerable <Graphic> graphics = e.DirectlyOver(10, new GraphicsLayer[] { featureLayer });
                foreach (Graphic graphic in graphics)
                {
                    // if editable, make the editable fields enabled. Otherwise disable them
                    if (featureLayer.IsUpdateAllowed(graphic))
                    {
                        RotationTB.IsEnabled    = true;
                        DescriptionTB.IsEnabled = true;
                        DateTB.IsEnabled        = true;
                        TypeButton.IsEnabled    = true;
                    }
                    else
                    {
                        RotationTB.IsEnabled    = false;
                        DescriptionTB.IsEnabled = false;
                        DateTB.IsEnabled        = false;
                        TypeButton.IsEnabled    = false;
                    }

                    // show the attribute page for the first of the graphics returned
                    FeatureInfoPage.IsOpen   = true;
                    ApplicationBar.IsVisible = false;

                    FeatureInfoPage.DataContext = graphic;

                    // select the type value in the ListBoxes to match the graphic's attributes
                    var typeMatches = FeatureTypeListBox.Items.Where(a => (a as TemplateItem).ID.Equals(graphic.Attributes["eventtype"]));
                    if (typeMatches.Any())
                    {
                        FeatureTypeListBox.SelectedItem = typeMatches.First();
                    }

                    return;
                }
            }

            // move a held feature
            if (e.Gesture == GestureType.Hold)
            {
                IEnumerable <Graphic> graphics = e.DirectlyOver(10, new GraphicsLayer[] { featureLayer });
                foreach (Graphic graphic in graphics)
                {
                    if (graphic != null && !graphic.Selected && featureLayer.IsUpdateAllowed(graphic))
                    {
                        Editor editor = LayoutRoot.Resources["MyEditor"] as Editor;
                        if (featureLayer.IsUpdateAllowed(graphic))
                        {
                            if (editor.EditVertices.CanExecute(null))
                            {
                                editor.EditVertices.Execute(null);
                            }
                        }
                        else
                        if (editor.CancelActive.CanExecute(null))
                        {
                            editor.CancelActive.Execute(null);
                        }
                    }
                    featureLayer.ClearSelection();
                    graphic.Select();
                }
            }
        }
 void AssociatedObject_MapGesture(object sender, Map.MapGestureEventArgs e)
 {
 }
        private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
        {
            if (e.Gesture == GestureType.Tap)
            {
                MyInfoWindow.IsOpen = false;

                double mapScale = MyMap.Scale;

                ArcGISDynamicMapServiceLayer alayer = null;
                DataTemplate dt    = null;
                int          layid = 0;

                foreach (Layer layer in MyMap.Layers)
                {
                    if (layer.GetValue(Document.PopupTemplatesProperty) != null)
                    {
                        alayer = layer as ArcGISDynamicMapServiceLayer;
                        IDictionary <int, DataTemplate> idict = layer.GetValue(Document.PopupTemplatesProperty) as IDictionary <int, DataTemplate>;
                        foreach (LayerInfo linfo in alayer.Layers)
                        {
                            if (((mapScale > linfo.MaxScale && // in scale range
                                  mapScale < linfo.MinScale) ||
                                 (linfo.MaxScale == 0.0 && // no scale dependency
                                  linfo.MinScale == 0.0) ||
                                 (mapScale > linfo.MaxScale && // minscale = 0.0 = infinity
                                  linfo.MinScale == 0.0)) &&
                                idict.ContainsKey(linfo.ID)) // id present in dictionary
                            {
                                layid = linfo.ID;
                                dt    = idict[linfo.ID];
                                break;
                            }
                        }
                    }
                }

                if (dt != null)
                {
                    QueryTask qt = new QueryTask(string.Format("{0}/{1}", alayer.Url, layid));
                    qt.ExecuteCompleted += (s, qe) =>
                    {
                        if (qe.FeatureSet.Features.Count > 0)
                        {
                            Graphic g = qe.FeatureSet.Features[0];
                            MyInfoWindow.Anchor          = e.MapPoint;
                            MyInfoWindow.ContentTemplate = dt;
                            MyInfoWindow.Content         = g.Attributes;
                            MyInfoWindow.IsOpen          = true;
                        }
                    };

                    ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
                    double   contractRatio = MyMap.Extent.Width / 20;
                    Envelope inputEnvelope = new Envelope(e.MapPoint.X - contractRatio,
                                                          e.MapPoint.Y - contractRatio,
                                                          e.MapPoint.X + contractRatio,
                                                          e.MapPoint.Y + contractRatio);
                    inputEnvelope.SpatialReference = MyMap.SpatialReference;
                    query.Geometry            = inputEnvelope;
                    query.OutSpatialReference = MyMap.SpatialReference;
                    query.OutFields.Add("*");

                    qt.ExecuteAsync(query);
                }
            }
        }
        private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
        {
            if (e.Gesture == GestureType.Tap)
            {
                GraphicsLayer glayer = MyMap.Layers["MySelectionGraphicsLayer"] as GraphicsLayer;
                glayer.Graphics.Clear();

                MyInfoWindow.IsOpen         = false;
                chartDetailsContent.Content = null;

                double mapScale = MyMap.Scale;

                ArcGISTiledMapServiceLayer alayer = null;
                DataTemplate dt    = null;
                int          layid = 0;

                foreach (Layer layer in MyMap.Layers)
                {
                    if (layer.GetValue(Document.PopupTemplatesProperty) != null)
                    {
                        alayer = layer as ArcGISTiledMapServiceLayer;
                        IDictionary <int, DataTemplate> idict = layer.GetValue(Document.PopupTemplatesProperty) as IDictionary <int, DataTemplate>;

                        foreach (LayerInfo linfo in alayer.Layers)
                        {
                            if (((mapScale > linfo.MaxScale && // in scale range
                                  mapScale < linfo.MinScale) ||
                                 (linfo.MaxScale == 0.0 && // no scale dependency
                                  linfo.MinScale == 0.0) ||
                                 (mapScale > linfo.MaxScale && // minscale = 0.0 = infinity
                                  linfo.MinScale == 0.0)) &&
                                idict.ContainsKey(linfo.ID)) // id present in dictionary
                            {
                                layid = linfo.ID;
                                dt    = idict[linfo.ID];
                                break;
                            }
                        }
                        if (dt != null)
                        {
                            QueryTask qt = new QueryTask(string.Format("{0}/{1}", alayer.Url, layid));
                            qt.ExecuteCompleted += (s, qe) =>
                            {
                                if (qe.FeatureSet.Features.Count > 0)
                                {
                                    Graphic g = qe.FeatureSet.Features[0];
                                    MyInfoWindow.Anchor          = e.MapPoint;
                                    popupContent.ContentTemplate = dt;
                                    popupContent.Content         = g.Attributes;
                                    MyInfoWindow.IsOpen          = true;

                                    SolidColorBrush symbolColor = new SolidColorBrush(Colors.Cyan);

                                    if (g.Geometry is ESRI.ArcGIS.Client.Geometry.Polygon || g.Geometry is Envelope)
                                    {
                                        g.Symbol = new SimpleFillSymbol()
                                        {
                                            BorderBrush     = symbolColor,
                                            BorderThickness = 2
                                        };
                                    }
                                    else if (g.Geometry is ESRI.ArcGIS.Client.Geometry.Polyline)
                                    {
                                        g.Symbol = new SimpleLineSymbol()
                                        {
                                            Color = symbolColor
                                        };
                                    }
                                    else // Point
                                    {
                                        g.Symbol = new SimpleMarkerSymbol()
                                        {
                                            Color = symbolColor,
                                            Size  = 12
                                        };
                                    }
                                    glayer.Graphics.Add(g);
                                }
                            };

                            ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query()
                            {
                                Geometry            = e.MapPoint,
                                OutSpatialReference = MyMap.SpatialReference,
                                ReturnGeometry      = true
                            };
                            query.OutFields.Add("*");

                            qt.ExecuteAsync(query);
                        }
                    }
                }
            }
        }