Ejemplo n.º 1
0
        /// <summary>
        /// Calculates the shortest line from the selected park to the stadium and displays it's length and shows the line on the map
        /// </summary>
        private void MapView_OnMapClick(object sender, TouchMapViewEventArgs e)
        {
            LayerOverlay layerOverlay = (LayerOverlay)mapView.Overlays["layerOverlay"];

            ShapeFileFeatureLayer friscoParks       = (ShapeFileFeatureLayer)layerOverlay.Layers["friscoParks"];
            InMemoryFeatureLayer  stadiumLayer      = (InMemoryFeatureLayer)layerOverlay.Layers["stadiumLayer"];
            InMemoryFeatureLayer  shortestLineLayer = (InMemoryFeatureLayer)layerOverlay.Layers["shortestLineLayer"];

            // Query the friscoParks layer to get the first feature closest to the map tap event
            var park = friscoParks.QueryTools.GetFeaturesNearestTo(e.PointInWorldCoordinate, GeographyUnit.Meter, 1,
                                                                   ReturningColumnsType.NoColumns).First();

            // Get the stadium feature from the stadiumLayer
            var stadium = stadiumLayer.InternalFeatures[0];

            // Get the shortest line from the selected park to the stadium
            var shortestLine = park.GetShape().GetShortestLineTo(stadium, GeographyUnit.Meter);

            // Show the shortestLine on the map
            shortestLineLayer.InternalFeatures.Clear();
            shortestLineLayer.InternalFeatures.Add(new Feature(shortestLine));
            layerOverlay.Refresh();

            // Get the area of the first feature
            var length = shortestLine.GetLength(GeographyUnit.Meter, DistanceUnit.Kilometer);

            // Display the shortestLine's length in the distanceResult TextBox
            distanceResult.Text = $"{length:f3} km";
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Perform the reverse geocode when the user taps on the map
        /// </summary>
        private void mapView_MapSingleTap(object sender, TouchMapViewEventArgs e)
        {
            // Set the coordinates in the UI
            txtCoordinates.Text = string.Format("{0},{1}", e.PointInWorldCoordinate.Y.ToString("0.000000"), e.PointInWorldCoordinate.X.ToString("0.000000"));

            // Run the reverse geocode
            PerformReverseGeocode();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Set the map to 'Polygon Drawing Mode' when the user taps on the map without panning
 /// </summary>
 private void MapView_OnMapClick(object sender, TouchMapViewEventArgs e)
 {
     if (!(mapView.TrackOverlay.TrackMode == TrackMode.Polygon))
     {
         // Set the drawing mode to 'Polygon'
         mapView.TrackOverlay.TrackMode = TrackMode.Polygon;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Set the map to 'Polygon Drawing Mode' when the user taps on the map without panning
 /// </summary>
 private void mapView_MapSingleTap(object sender, TouchMapViewEventArgs e)
 {
     if (mapView.TrackOverlay.TrackMode != TrackMode.Polygon)
     {
         // Set the drawing mode to 'Polygon'
         mapView.TrackOverlay.TrackMode = TrackMode.Polygon;
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Pull data from the selected feature and display it when tapped
        /// </summary>
        private void MapView_OnMapSingleTap(object sender, TouchMapViewEventArgs e)
        {
            // Get the selected feature based on the map tap location
            Feature selectedFeature = GetFeatureFromLocation(e.PointInWorldCoordinate);

            // If a feature was selected, get the data from it and display it
            if (selectedFeature != null)
            {
                DisplayFeatureInfo(selectedFeature);
            }
        }
Ejemplo n.º 6
0
        private void mapView_MapClick(object sender, TouchMapViewEventArgs e)
        {
            // Get the selected feature based on the tapped location
            Collection <Feature> selectedFeatures = GetFeaturesFromLocation(e.PointInWorldCoordinate);

            // If a feature was selected, get the data from it and display it
            if (selectedFeatures != null)
            {
                DisplayFeatureInfo(selectedFeatures);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Map event that fires whenever the user taps on the map. Gets the closest feature from the tap event and calculates the center point
        /// </summary>
        private void MapView_OnMapClick(object sender, TouchMapViewEventArgs e)
        {
            LayerOverlay          layerOverlay  = (LayerOverlay)mapView.Overlays["layerOverlay"];
            ShapeFileFeatureLayer censusHousing = (ShapeFileFeatureLayer)layerOverlay.Layers["censusHousing"];

            // Query the censusHousing layer to get the first feature closest to the map tap event
            var feature = censusHousing.QueryTools.GetFeaturesNearestTo(e.PointInWorldCoordinate, GeographyUnit.Meter, 1,
                                                                        ReturningColumnsType.NoColumns).First();

            CalculateCenterPoint(feature);
        }
Ejemplo n.º 8
0
        private async void mapView_MapSingleTap(object sender, TouchMapViewEventArgs e)
        {
            //I go to find the layer and then loop through all of the features and rotate them
            var polygonLayer = (InMemoryFeatureLayer)mapView.FindFeatureLayer("PolygonLayer");

            var features = polygonLayer.QueryTools.GetFeaturesContaining(e.PointInWorldCoordinate, ReturningColumnsType.AllColumns);

            if (features.Count > 0)
            {
                await DisplayAlert("Alert", $"Feature: {features[0].Id} DataPoint1: {features[0].ColumnValues["DataPoint1"]}", "OK");
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Adds a marker to the simpleMarkerOverlay where the map tap event occurred.
        /// </summary>
        private void MapView_OnMapTouch(object sender, TouchMapViewEventArgs e)
        {
            SimpleMarkerOverlay simpleMarkerOverlay = (SimpleMarkerOverlay)mapView.Overlays["simpleMarkerOverlay"];

            // Create a marker at the position the mouse was tapped
            var marker = new Marker()
            {
                Position    = e.PointInWorldCoordinate,
                ImageSource = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Resources/AQUA.png"),
                YOffset     = -17
            };

            // Add the marker to the simpleMarkerOverlay and refresh the map
            simpleMarkerOverlay.Markers.Add(marker);
            simpleMarkerOverlay.Refresh();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Event handler that finds the nearest feature and removes it from the layer
        /// </summary>
        private void MapView_SingleTap(object sender, TouchMapViewEventArgs e)
        {
            LayerOverlay         layerOverlay = (LayerOverlay)mapView.Overlays["layerOverlay"];
            InMemoryFeatureLayer featureLayer = (InMemoryFeatureLayer)layerOverlay.Layers["featureLayer"];

            // Query the layer for the closest feature within 100 meters
            Collection <Feature> closestFeatures = featureLayer.QueryTools.GetFeaturesNearestTo(e.PointInWorldCoordinate, GeographyUnit.Meter, 1, new Collection <string>(), 100, DistanceUnit.Meter);

            // If a feature was found, remove it from the layer
            if (closestFeatures.Count > 0)
            {
                featureLayer.InternalFeatures.Remove(closestFeatures[0]);

                // Refresh the layerOverlay to show the results
                layerOverlay.Refresh();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Calculates the area of a feature selected on the map and displays it in the areaResult TextBox
        /// </summary>
        private void MapView_OnMapClick(object sender, TouchMapViewEventArgs e)
        {
            LayerOverlay layerOverlay = (LayerOverlay)mapView.Overlays["layerOverlay"];

            ShapeFileFeatureLayer friscoParks       = (ShapeFileFeatureLayer)layerOverlay.Layers["friscoParks"];
            InMemoryFeatureLayer  selectedAreaLayer = (InMemoryFeatureLayer)layerOverlay.Layers["selectedAreaLayer"];

            // Query the friscoParks layer to get the first feature closest to the map tap event
            var feature = friscoParks.QueryTools.GetFeaturesNearestTo(e.PointInWorldCoordinate, GeographyUnit.Meter, 1,
                                                                      ReturningColumnsType.NoColumns).First();

            // Show the selected feature on the map
            selectedAreaLayer.InternalFeatures.Clear();
            selectedAreaLayer.InternalFeatures.Add(feature);
            layerOverlay.Refresh();

            // Get the area of the first feature
            var area = ((AreaBaseShape)feature.GetShape()).GetArea(GeographyUnit.Meter, AreaUnit.SquareKilometers);

            // Display the selectedArea's area in the areaResult TextBox
            areaResult.Text = $"{area:f3} sq km";
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Calculates the length of a line selected on the map and displays it in the lengthResult TextBox
        /// </summary>
        private void MapView_OnMapClick(object sender, TouchMapViewEventArgs e)
        {
            LayerOverlay layerOverlay = (LayerOverlay)mapView.Overlays["layerOverlay"];

            ShapeFileFeatureLayer friscoTrails      = (ShapeFileFeatureLayer)layerOverlay.Layers["friscoTrails"];
            InMemoryFeatureLayer  selectedLineLayer = (InMemoryFeatureLayer)layerOverlay.Layers["selectedLineLayer"];

            // Query the friscoTrails layer to get the first feature closest to the map tap event
            var feature = friscoTrails.QueryTools.GetFeaturesNearestTo(e.PointInWorldCoordinate, GeographyUnit.Meter, 1,
                                                                       ReturningColumnsType.NoColumns).First();

            // Show the selected feature on the map
            selectedLineLayer.InternalFeatures.Clear();
            selectedLineLayer.InternalFeatures.Add(feature);
            layerOverlay.Refresh();

            // Get the length of the first feature
            var length = ((LineBaseShape)feature.GetShape()).GetLength(GeographyUnit.Meter, DistanceUnit.Kilometer);

            // Display the selectedLine's length in the lengthResult TextBox
            lengthResult.Text = $"{length:f3} km";
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Perform the spatial query when a new point is drawn
 /// </summary>
 private void MapView_OnMapTap(object sender, TouchMapViewEventArgs e)
 {
     GetFeaturesContaining(e.PointInWorldCoordinate);
 }
Ejemplo n.º 14
0
 private async void mapView_MapTap(object sender, TouchMapViewEventArgs e)
 {
     //Run the timezone info query
     await GetTimeZoneInfo(e.PointInWorldCoordinate.X, e.PointInWorldCoordinate.Y);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Perform the spatial query when a new point is drawn
 /// </summary>
 private void MapView_OnMapClick(object sender, TouchMapViewEventArgs e)
 {
     GetFeaturesWithinDistance(e.PointInWorldCoordinate);
 }