private void _myMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Get the user-tapped location
            MapPoint mapLocation = e.Location;

            // Project the user-tapped map point location to a geometry
            Geometry myGeometry = GeometryEngine.Project(mapLocation, SpatialReferences.Wgs84);

            // Convert to geometry to a traditional Lat/Long map point
            MapPoint projectedLocation = (MapPoint)myGeometry;

            // Format the display callout string based upon the projected map point (example: "Lat: 100.123, Long: 100.234")
            string mapLocationDescription = string.Format("Lat: {0:F3} Long:{1:F3}", projectedLocation.Y, projectedLocation.X);

            // Create a new callout definition using the formatted string
            CalloutDefinition myCalloutDefinition = new CalloutDefinition("Location:", mapLocationDescription);

            // Display the callout
            _myMapView.ShowCalloutAt(mapLocation, myCalloutDefinition);
        }
Beispiel #2
0
        private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            Exception error = null;

            try
            {
                var result = await mapView.IdentifyLayersAsync(e.Position, 3, false);

                // Retrieves or builds Popup from IdentifyLayerResult
                var popup = GetPopup(result);

                // Displays callout and updates visibility of PopupViewer
                if (popup != null)
                {
                    var callout = new CalloutDefinition(popup.GeoElement);
                    callout.Tag           = popup;
                    callout.ButtonImage   = InfoIcon;
                    callout.OnButtonClick = new Action <object>((s) =>
                    {
                        popupViewer.Hidden       = false;
                        popupViewer.PopupManager = new PopupManager(popup);
                    });
                    mapView.ShowCalloutForGeoElement(popup.GeoElement, e.Position, callout);
                }
                else
                {
                    popupViewer.PopupManager = null;
                    popupViewer.Hidden       = true;
                }
            }
            catch (Exception ex)
            {
                error = ex;
            }
            if (error != null)
            {
                var alert = UIAlertController.Create(error.GetType().Name, error.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                this.PresentViewController(alert, true, null);
            }
        }
        private void MapView_Tapped(object sender, GeoViewInputEventArgs e)
        {
            // Get the tapped point - this is in the map's spatial reference,
            // which in this case is WebMercator because that is the SR used by the included basemaps.
            MapPoint tappedPoint = e.Location;

            // Update the graphics.
            _myMapView.GraphicsOverlays[0].Graphics.Clear();
            _myMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(tappedPoint));

            // Project the point to WGS84
            MapPoint projectedPoint = (MapPoint)GeometryEngine.Project(tappedPoint, SpatialReferences.Wgs84);

            // Format the results in strings.
            string originalCoords  = $"Original: {tappedPoint.X:F4}, {tappedPoint.Y:F4}";
            string projectedCoords = $"Projected: {projectedPoint.X:F4}, {projectedPoint.Y:F4}";

            // Define a callout and show it in the map view.
            CalloutDefinition calloutDef = new CalloutDefinition(projectedCoords, originalCoords);

            _myMapView.ShowCalloutAt(tappedPoint, calloutDef);
        }
Beispiel #4
0
        private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            Exception error = null;

            try
            {
                var result = await mapView.IdentifyLayersAsync(e.Position, 3, false);

                // Retrieves or builds Popup from IdentifyLayerResult
                var popup = GetPopup(result);

                // Displays callout and updates visibility of PopupViewer
                if (popup != null)
                {
                    var callout = new CalloutDefinition(popup.GeoElement);
                    callout.Tag           = popup;
                    callout.ButtonImage   = InfoIcon;
                    callout.OnButtonClick = OnPopupInfoButtonClicked;
                    mapView.ShowCalloutForGeoElement(popup.GeoElement, e.Position, callout);
                }
                else
                {
                    popupViewer.PopupManager = null;
                    popupViewer.Visibility   = Android.Views.ViewStates.Gone;
                }
            }
            catch (Exception ex)
            {
                error = ex;
            }
            if (error != null)
            {
                var alert = new AlertDialog.Builder(this);
                alert.SetTitle(error.GetType().Name);
                alert.SetMessage(error.Message);
                alert.SetPositiveButton("OK", (a, b) => { });
                RunOnUiThread(() => alert.Show());
            }
        }
        private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            Exception error = null;

            try
            {
                var result = await mapView.IdentifyLayersAsync(e.Position, 3, false);

                // Retrieves or builds Popup from IdentifyLayerResult
                var popup = GetPopup(result);

                // Displays callout and updates visibility of PopupViewer
                if (popup != null)
                {
                    var callout = new CalloutDefinition(popup.GeoElement);
                    callout.Tag           = popup;
                    callout.ButtonImage   = InfoIcon;
                    callout.OnButtonClick = new Action <object>((s) =>
                    {
                        popupViewer.IsVisible    = true;
                        popupViewer.PopupManager = new PopupManager(s as Popup);
                    });
                    mapView.ShowCalloutForGeoElement(popup.GeoElement, e.Position, callout);
                }
                else
                {
                    popupViewer.PopupManager = null;
                    popupViewer.IsVisible    = false;
                }
            }
            catch (Exception ex)
            {
                error = ex;
            }
            if (error != null)
            {
                await DisplayAlert(error.GetType().Name, error.Message, "OK");
            }
        }
Beispiel #6
0
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            // First clear any existing selections
            ClearAllSelections();

            // Perform the identify operation
            IReadOnlyList <IdentifyLayerResult> results = await MyMapView.IdentifyLayersAsync(e.Position, 5, false);

            // Return if there are no results
            if (results.Count < 1)
            {
                return;
            }

            // Get the results that are from ENC layers
            IEnumerable <IdentifyLayerResult> encResults = results.Where(result => result.LayerContent is EncLayer);

            // Get the ENC results that have features
            IEnumerable <IdentifyLayerResult> encResultsWithFeatures = encResults.Where(result => result.GeoElements.Count > 0);

            // Get the first result with ENC features
            IdentifyLayerResult firstResult = encResultsWithFeatures.First();

            // Get the layer associated with this set of results
            EncLayer containingLayer = firstResult.LayerContent as EncLayer;

            // Select the smallest (area) feature in the layer.
            EncFeature smallestFeature = (EncFeature)firstResult.GeoElements.OrderBy(f => GeometryEngine.Area(f.Geometry)).First();

            // Select the feature.
            containingLayer.SelectFeature(smallestFeature);

            // Create the callout definition.
            CalloutDefinition definition = new CalloutDefinition(smallestFeature.Acronym, smallestFeature.Description);

            // Show the callout
            MyMapView.ShowCalloutAt(e.Location, definition);
        }
        private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // First clear any existing selections
            ClearAllSelections();

            // Perform the identify operation
            IReadOnlyList <IdentifyLayerResult> results = await _myMapView.IdentifyLayersAsync(e.Position, 5, false);

            // Return if there are no results
            if (results.Count < 1)
            {
                return;
            }

            // Get the results that are from ENC layers
            IEnumerable <IdentifyLayerResult> encResults = results.Where(result => result.LayerContent is EncLayer);

            // Get the ENC results that have features
            IEnumerable <IdentifyLayerResult> encResultsWithFeatures = encResults.Where(result => result.GeoElements.Count > 0);

            // Get the first result with ENC features
            IdentifyLayerResult firstResult = encResultsWithFeatures.First();

            // Get the layer associated with this set of results
            EncLayer containingLayer = firstResult.LayerContent as EncLayer;

            // Get the first identified ENC feature
            EncFeature firstFeature = firstResult.GeoElements.First() as EncFeature;

            // Select the feature
            containingLayer.SelectFeature(firstFeature);

            // Create the callout definition
            CalloutDefinition definition = new CalloutDefinition(firstFeature.Acronym, firstFeature.Description);

            // Show the callout
            _myMapView.ShowCalloutAt(e.Location, definition);
        }
        /// <summary>
        /// Shows a callout for any tapped graphics
        /// </summary>
        private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Search for the graphics underneath the user's tap
            IReadOnlyList<IdentifyGraphicsOverlayResult> results = await MyMapView.IdentifyGraphicsOverlaysAsync(e.Position, 12, false);

            // Clear callouts and return if there was no result
            if (results.Count < 1 || results.First().Graphics.Count < 1) { MyMapView.DismissCallout(); return; }

            // Get the first graphic from the first result
            Graphic matchingGraphic = results.First().Graphics.First();

            // Get the title; manually added to the point's attributes in UpdateSearch
            String title = matchingGraphic.Attributes["Match_Title"] as String;

            // Get the address; manually added to the point's attributes in UpdateSearch
            String address = matchingGraphic.Attributes["Match_Address"] as String;

            // Define the callout
            CalloutDefinition calloutBody = new CalloutDefinition(title, address);

            // Show the callout on the map at the tapped location
            MyMapView.ShowCalloutAt(e.Location, calloutBody);
        }
        private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            try
            {
                // Clear existing callout and graphics.
                MyMapView.DismissCallout();
                MyMapView.GraphicsOverlays[0].Graphics.Clear();

                // Add a graphic for the tapped point.
                Graphic pinGraphic = await GraphicForPoint(e.Location);

                MyMapView.GraphicsOverlays[0].Graphics.Add(pinGraphic);

                // Reverse geocode to get addresses.
                ReverseGeocodeParameters parameters = new ReverseGeocodeParameters();
                parameters.ResultAttributeNames.Add("*");
                parameters.MaxResults = 1;
                IReadOnlyList <GeocodeResult> addresses = await _geocoder.ReverseGeocodeAsync(e.Location, parameters);

                // Get the first result.
                GeocodeResult address = addresses.First();

                // Use the address as the callout title.
                string calloutTitle  = address.Attributes["Street"].ToString();
                string calloutDetail = address.Attributes["City"] + ", " + address.Attributes["State"] + " " + address.Attributes["ZIP"];

                // Define the callout.
                CalloutDefinition calloutBody = new CalloutDefinition(calloutTitle, calloutDetail);

                // Show the callout on the map at the tapped location.
                MyMapView.ShowCalloutForGeoElement(pinGraphic, e.Position, calloutBody);
            }
            catch (Exception ex)
            {
                await new MessageDialog2(ex.ToString(), "Error").ShowAsync();
            }
        }
Beispiel #10
0
        /// <summary>
        /// Shows a callout with information about the graphics/features at that location
        /// </summary>
        /// <param name="position"></param>
        private async void ShowCalloutTopDispatches(Point position)
        {
            // Check if a cell is already being identified
            if (_isIdentifying)
            {
                _nextIdentifyAction = () => ShowCalloutTopDispatches(position);
                return;
            }

            // Set variable to true to prevent concurrent identify calls.
            _isIdentifying = true;

            try
            {
                // Get the result for where the user hovered on the raster layer.
                var identifyResult = await this.MapView.IdentifyGraphicsOverlayAsync(this.Dispatches.FeatureGraphicsLayer, position, 1, false, 1);

                var graphic = identifyResult.Graphics.FirstOrDefault() as CustomGraphic;
                // If no cell was identified, dismiss the callout.
                if (graphic != null && graphic.ID != _previousCallout)
                {
                    this.MapView.DismissCallout();
                    _previousCallout = -1;
                }
                else if (graphic == null)
                {
                    this.MapView.DismissCallout();
                    _previousCallout = -1;
                    return;
                }
                else if (graphic != null && graphic.ID == _previousCallout)
                {
                    return;
                }
                _previousCallout = graphic.ID;
                // Create a StringBuilder to display information to the user.
                var stringBuilder = new StringBuilder();

                // Get the identified raster cell.
                GeoElement cell = graphic;

                // Loop through the attributes (key/value pairs).
                foreach (KeyValuePair <string, object> keyValuePair in cell.Attributes)
                {
                    // Add the key/value pair to the string builder.
                    stringBuilder.AppendLine($"{keyValuePair.Key}: {keyValuePair.Value}");
                }

                var mapPoint = this.MapView.ScreenToLocation(position).ToWgs84() as MapPoint;
                // Get the x and y values of the cell.
                double x = position.X;
                double y = position.Y;

                // Add the X & Y coordinates where the user clicked raster cell to the string builder.
                stringBuilder.AppendLine($"X: {Math.Round(mapPoint.X, 4)}\nY: {Math.Round(mapPoint.Y, 4)}");

                // Create a callout using the string.
                var definition = new CalloutDefinition(stringBuilder.ToString());

                // TODO: To show a custom view for the callout, use this.MapView.ShowCalloutAt(graphic.Geometry as MapPoint, this.MyView);
                // Display the call out in the map view.
                this.MapView.ShowCalloutAt(graphic.Geometry as MapPoint, definition);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }
            finally
            {
                _isIdentifying = false;
            }

            // Check if there is a new position to identify.
            if (_nextIdentifyAction != null)
            {
                Action action = _nextIdentifyAction;

                // Clear the queued identify action.
                _nextIdentifyAction = null;

                // Run the next action.
                action();
            }
        }
 public static CalloutDefinition CreateCalloutDefinition(string calloutType, string tenantId, string condition, int ID, global::System.DateTimeOffset created, global::System.DateTimeOffset modified)
 {
     CalloutDefinition calloutDefinition = new CalloutDefinition();
     calloutDefinition.CalloutType = calloutType;
     calloutDefinition.TenantId = tenantId;
     calloutDefinition.Condition = condition;
     calloutDefinition.Id = ID;
     calloutDefinition.Created = created;
     calloutDefinition.Modified = modified;
     return calloutDefinition;
 }
 public void AddToCalloutDefinitions(CalloutDefinition calloutDefinition)
 {
     base.AddObject("CalloutDefinitions", calloutDefinition);
 }
Beispiel #13
0
        private async void IdentifyCell(Point position)
        {
            // Check if a cell is already being identified
            if (_isIdentifying)
            {
                _nextIdentifyAction = () => IdentifyCell(position);
                return;
            }

            // Set variable to true to prevent concurrent identify calls.
            _isIdentifying = true;

            try
            {
                // Get the result for where the user hovered on the raster layer.
                IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_rasterLayer, position, 1, false, 1);

                // If no cell was identified, dismiss the callout.
                if (!identifyResult.GeoElements.Any())
                {
                    MyMapView.DismissCallout();
                    return;
                }

                // Create a StringBuilder to display information to the user.
                var stringBuilder = new StringBuilder();

                // Get the identified raster cell.
                GeoElement cell = identifyResult.GeoElements.First();

                // Loop through the attributes (key/value pairs).
                foreach (KeyValuePair <string, object> keyValuePair in cell.Attributes)
                {
                    // Add the key/value pair to the string builder.
                    stringBuilder.AppendLine($"{keyValuePair.Key}: {keyValuePair.Value}");
                }

                // Get the x and y values of the cell.
                double x = cell.Geometry.Extent.XMin;
                double y = cell.Geometry.Extent.YMin;

                // Add the X & Y coordinates where the user clicked raster cell to the string builder.
                stringBuilder.AppendLine($"X: {Math.Round(x, 4)}\nY: {Math.Round(y, 4)}");

                // Create a callout using the string.
                var definition = new CalloutDefinition(stringBuilder.ToString());

                // Display the call out in the map view.
                MyMapView.ShowCalloutAt(MyMapView.ScreenToLocation(position), definition);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }
            finally
            {
                _isIdentifying = false;
            }

            // Check if there is a new position to identify.
            if (_nextIdentifyAction != null)
            {
                Action action = _nextIdentifyAction;

                // Clear the queued identify action.
                _nextIdentifyAction = null;

                // Run the next action.
                action();
            }
        }
        private async void InitializeMarkers(string buoyData)
        {
            // create 2d array from buoy data string
            string newResults    = Regex.Replace(buoyData, " {4,}", " ");
            string newResultsTwo = Regex.Replace(newResults, " {2,}", " ");
            char   delimiter     = '\n';

            String[] data = newResultsTwo.Split(delimiter);

            int length = data.Length;


            String[,] dataParsed = new String[length, 22];

            char delimiterTwo = ' ';

            for (int i = 0; i < data.Length; i++)
            {
                String[] fields = data[i].Split(delimiterTwo);

                for (int j = 0; j < fields.Length; j++)
                {
                    dataParsed[i, j] = fields[j];
                }
            }



            // Create simple marker symbol for user location
            SimpleMarkerSymbol userMarker = new SimpleMarkerSymbol()
            {
                Color = Color.Red,
                Size  = 10,
                Style = SimpleMarkerSymbolStyle.Diamond
            };

            // Create simple marker symbol for buoy locations
            SimpleMarkerSymbol buoyMarker = new SimpleMarkerSymbol()
            {
                Color = Color.Black,
                Size  = 10,
                Style = SimpleMarkerSymbolStyle.Circle
            };

            // Create graphics overlay for buoys
            GraphicsOverlay buoys = new GraphicsOverlay();

            buoys.Id = "BuoyLayer";

            //get user location
            string userLat = "";
            string userLon = "";

            try
            {
                var request      = new GeolocationRequest(GeolocationAccuracy.Medium);
                var userLocation = await Geolocation.GetLocationAsync(request);

                if (userLocation != null)
                {
                    userLat = userLocation.Latitude.ToString();
                    userLon = userLocation.Longitude.ToString();

                    string   userLocationFormatted = userLat + " " + userLon;
                    MapPoint userMapPoint          = CoordinateFormatter.FromLatitudeLongitude(userLocationFormatted, SpatialReferences.Wgs84);
                    Graphic  userGraphic           = new Graphic(userMapPoint, userMarker);

                    buoys.Graphics.Add(userGraphic);
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }

            //MapPoint startingLocation;
            length = data.Length - 1;

            // create buoy marker for each location from buoy array
            for (int i = 3; i < length; i++)
            {
                if (Convert.ToDouble(dataParsed[i, 2]) > -100 && Convert.ToDouble(dataParsed[i, 2]) < -80)
                {
                    if (Convert.ToDouble(dataParsed[i, 1]) > 17 && Convert.ToDouble(dataParsed[i, 1]) < 31)
                    {
                        string   location         = dataParsed[i, 1] + " " + dataParsed[i, 2];
                        MapPoint startingLocation = CoordinateFormatter.FromLatitudeLongitude(location, SpatialReferences.Wgs84);

                        Graphic graphicWithBuoy = new Graphic(startingLocation, buoyMarker);
                        buoys.Graphics.Add(graphicWithBuoy);
                    }
                }
            }

            // add overlay to map
            _mapView.GraphicsOverlays.Add(buoys);

            // method for when user clicks on buoy
            _mapView.GeoViewTapped += async(s, e) =>
            {
                try
                {
                    // identify buoy layer
                    IdentifyGraphicsOverlayResult identifyResults = await _mapView.IdentifyGraphicsOverlayAsync(
                        buoys,
                        e.Position,
                        10d,
                        false,
                        1

                        );

                    Geometry          myGeo      = GeometryEngine.Project(e.Location, SpatialReferences.Wgs84);
                    MapPoint          projection = (MapPoint)myGeo;
                    CalloutDefinition myCallout;
                    int latitidueFinal = 0;


                    //compare user click point to buoy locations from array
                    if (identifyResults.Graphics.Count > 0)
                    {
                        string description = " ";
                        for (int i = 3; i < length; i++)
                        {
                            for (int j = 1; j < 3; j++)
                            {
                                double latNDBC        = Convert.ToDouble(dataParsed[i, 1]);
                                double latNDBCRounded = Math.Round(latNDBC, 1);

                                double latClick        = Convert.ToDouble(projection.Y);
                                double latClickRounded = Math.Round(latClick, 1);

                                double lowerLat = latClickRounded - .1;
                                double upperLat = latClickRounded + .1;

                                double lonNDBC        = Convert.ToDouble(dataParsed[i, 2]);
                                double lonNDBCRounded = Math.Round(lonNDBC, 1);

                                double lonClick        = Convert.ToDouble(projection.X);
                                double lonClickRounded = Math.Round(lonClick, 1);

                                double lowerLon = lonClickRounded - .1;
                                double upperLon = lonClickRounded + .1;


                                // find the line in the array for the buoy the user clicked on
                                if (lowerLat <= latNDBCRounded && upperLat >= latNDBCRounded && lowerLon <= lonNDBCRounded && upperLon >= lonNDBCRounded)
                                {
                                    latitidueFinal = i;
                                }
                            }
                        }


                        // translate degree number into NSWE
                        string degrees = "";

                        double degreesDouble = Convert.ToDouble(dataParsed[latitidueFinal, 8]);
                        if (degreesDouble > 349 && degreesDouble <= 360)
                        {
                            degrees = "N";
                        }
                        else if (degreesDouble >= 0 && degreesDouble <= 11)
                        {
                            degrees = "N";
                        }
                        else if (degreesDouble > 11 && degreesDouble <= 34)
                        {
                            degrees = "NNE";
                        }
                        else if (degreesDouble > 34 && degreesDouble <= 56)
                        {
                            degrees = "NE";
                        }
                        else if (degreesDouble > 56 && degreesDouble <= 79)
                        {
                            degrees = "ENE";
                        }
                        else if (degreesDouble > 79 && degreesDouble <= 101)
                        {
                            degrees = "E";
                        }
                        else if (degreesDouble > 101 && degreesDouble <= 124)
                        {
                            degrees = "ESE";
                        }
                        else if (degreesDouble > 124 && degreesDouble <= 146)
                        {
                            degrees = "SE";
                        }
                        else if (degreesDouble > 146 && degreesDouble <= 169)
                        {
                            degrees = "SSE";
                        }
                        else if (degreesDouble > 169 && degreesDouble <= 191)
                        {
                            degrees = "S";
                        }
                        else if (degreesDouble > 191 && degreesDouble <= 214)
                        {
                            degrees = "SSW";
                        }
                        else if (degreesDouble > 214 && degreesDouble <= 236)
                        {
                            degrees = "SW";
                        }
                        else if (degreesDouble > 236 && degreesDouble <= 259)
                        {
                            degrees = "WSW";
                        }
                        else if (degreesDouble > 259 && degreesDouble <= 281)
                        {
                            degrees = "W";
                        }
                        else if (degreesDouble > 281 && degreesDouble <= 304)
                        {
                            degrees = "WNW";
                        }
                        else if (degreesDouble > 304 && degreesDouble <= 326)
                        {
                            degrees = "NW";
                        }
                        else if (degreesDouble > 326 && degreesDouble <= 349)
                        {
                            degrees = "NNW";
                        }



                        // create callout
                        string title    = dataParsed[latitidueFinal, 0];
                        string location = "Location: " + dataParsed[latitidueFinal, 1] + "N " + dataParsed[latitidueFinal, 2] + "W" + "\n";
                        string date     = " Date: " + dataParsed[latitidueFinal, 3] + "/" + dataParsed[latitidueFinal, 4] + "/" + dataParsed[latitidueFinal, 5] + " " + dataParsed[latitidueFinal, 6] + ":" + dataParsed[latitidueFinal, 7] + ":00 UTC" + "\n";
                        string winds    = "";

                        description += location;
                        description += date;
                        description += winds;

                        string airTemp   = "";
                        string waterTemp = "";
                        string dewpoint  = "";

                        if (dataParsed[latitidueFinal, 10] != "MM")
                        {
                            winds        = " Winds: " + degrees + "(" + dataParsed[latitidueFinal, 8] + ") at " + dataParsed[latitidueFinal, 9] + " kt gusting to " + dataParsed[latitidueFinal, 10] + " kt" + "\n";
                            description += winds;
                        }

                        else if (dataParsed[latitidueFinal, 10] == "MM")
                        {
                            winds        = " Winds: " + degrees + "(" + dataParsed[latitidueFinal, 8] + ") at " + dataParsed[latitidueFinal, 9] + " kt \n";
                            description += winds;
                        }

                        if (dataParsed[latitidueFinal, 17] != "MM")
                        {
                            airTemp      = " Air Temperature: " + dataParsed[latitidueFinal, 17] + " F" + "\n";
                            description += airTemp;
                        }
                        if (dataParsed[latitidueFinal, 18] != "MM")
                        {
                            waterTemp    = " Water Temperature: " + dataParsed[latitidueFinal, 18] + " F" + "\n";
                            description += waterTemp;
                        }
                        if (dataParsed[latitidueFinal, 19] != "MM")
                        {
                            dewpoint     = " Dew Point: " + dataParsed[latitidueFinal, 19] + " F" + "\n";
                            description += dewpoint;
                        }


                        myCallout = new CalloutDefinition(title, description);
                        _mapView.ShowCalloutAt(e.Location, myCallout);

                        latitidueFinal = 0;
                    }
                    else
                    {
                        _mapView.DismissCallout();
                    }
                }
                catch (Exception ex)
                {
                }
            };
        }
        private async void WaveSelected()
        {
            // clear existing overlays
            _mapView.GraphicsOverlays.Clear();

            //tide prediction array
            string[,] tidePrediction = new string[, ] {
                //Alabama
                { "30.2786", "-87.5550", "8730667" },
                { "30.2333", "-88.0200", "8734635" },
                { "30.2799", "-87.6843", "8731439" },
                { "30.3033", "-87.7350", "8731952" },
                { "30.2500", "-88.0750", "8735180" },
                { "30.4436", "-88.1139", "8735523" },
                { "30.3766", "-88.1586", "8738043" },
                { "30.4866", "-87.9345", "8733821" },
                { "30.5652", "-88.0880", "8735391" },
                { "30.6483", "-88.0583", "8736897" },
                { "30.6672", "-87.9364", "8733839" },
                { "30.7083", "-88.0433", "8737048" },
                { "30.7819", "-88.0736", "8737138" },
                { "30.8183", "-87.9150", "8737182" },
                { "30.3717", "-88.2750", "8739051" },
                { "30.4057", "-88.2477", "8739803" },

                //Mississippi
                { "30.4132", "-88.4029", "8740166" },
                { "30.3867", "-88.4400", "8740448" },
                { "30.3867", "-88.7733", "8743081" },
                { "30.2033", "-88.4417", "8740405" },
                { "30.2133", "-88.9717", "8740405" },
                { "30.2383", "-88.6667", "8742221" },
                { "30.3478", "-88.5058", "8741041" },
                { "30.3400", "-88.5333", "8741196" },
                { "30.3617", "-88.6633", "8742205" },
                { "30.3600", "-89.0817", "8745557" },
                { "30.3900", "-88.8567", "8743735" },
                { "30.4267", "-89.0533", "8745375" },
                { "30.4067", "-89.0267", "8745101" },
                { "30.2317", "-89.1167", "8745799" },
                { "30.3100", "-89.2450", "8746819" },
                { "30.3583", "-89.2733", "8748038" },
                { "30.3250", "-89.3250", "8747437" },
                { "30.2817", "-89.3667", "8747766" },
                { "30.2400", "-89.6150", "8749704" },

                //Louisiana
                { "30.1667", "-89.7367", "8761402" },
                { "30.2717", "-89.7933", "8761473" },
                { "30.3783", "-90.1600", "8761993" },
                { "30.0272", "-90.1133", "8761927" },
                { "30.0650", "-89.8000", "8761487" },
                { "30.0067", "-89.9367", "8761678" },
                { "29.8681", "-89.6732", "8761305" },
                { "30.1267", "-89.2217", "8760668" },
                { "30.0483", "-88.8717", "8760172" },
                { "29.8233", "-89.2700", "8760742" },
                { "29.5983", "-89.6183", "8761108" },
                { "29.4933", "-89.1733", "8760595" },
                { "29.3667", "-89.3450", "8760841" },
                { "29.2283", "-89.0500", "8760424" },
                { "29.3866", "-89.3801", "8760889" },
                { "30.0000", "-89.9333", "8760412" },
                { "29.2633", "-89.9567", "8761724" },
                { "29.2667", "-89.9667", "TEC4455" },
                { "29.3100", "-89.9383", "8761677" },
                { "29.3183", "-89.9800", "8761742" },
                { "29.4267", "-89.9767", "8761732" },
                { "29.6667", "-90.1117", "8761899" },
                { "29.2100", "-90.0400", "8761826" },
                { "29.1142", "-90.1993", "8762075" },
                { "29.2483", "-90.2117", "8762084" },
                { "29.3733", "-90.2650", "8762184" },
                { "29.0867", "-90.5267", "8762675" },
                { "29.0767", "-90.2850", "8762223" },
                { "29.1283", "-90.4233", "8762481" },
                { "29.0783", "-90.5867", "8762850" },
                { "29.2450", "-90.6617", "8762928" },
                { "29.0717", "-90.6400", "8762888" },
                { "29.0633", "-90.8067", "8763206" },
                { "29.0633", "-90.9617", "8763506" },
                { "29.1748", "-90.9764", "8763535" },
                { "29.3675", "-91.3839", "8764314" },
                { "29.3333", "-91.3533", "8764256" },
                { "29.4733", "-91.3050", "8764165" },
                { "29.7433", "-91.2300", "8764025" },
                { "29.5183", "-91.5550", "8764634" },
                { "29.4200", "-91.5933", "8764706" },
                { "29.4850", "-91.7633", "8765026" },
                { "29.5233", "-92.0433", "8765568" },
                { "28.9150", "-91.0717", "8763719" },
                { "29.7350", "-91.7133", "8764931" },
                { "29.5800", "-92.0350", "8765551" },
                { "29.7134", "-91.8800", "8765251" },
                { "29.8372", "-91.8375", "8765148" },
                { "29.5517", "-92.3052", "8766072" },
                { "29.7500", "-93.1000", "TEC4495" },
                { "29.7682", "-93.3429", "8768094" },
                { "30.1902", "-93.3008", "8767961" },
                { "30.2236", "-93.2217", "8767816" },

                //Texas

                { "29.7284", "-93.8701", "8770570" },
                { "29.6894", "-93.8419", "8770822" },
                { "29.8671", "-93.9310", "8770475" },
                { "29.9800", "-93.8817", "8770520" },
                { "29.3573", "-94.7248", "8771341" },
                { "29.3267", "-94.6933", "8771416" },
                { "29.3100", "-94.7933", "8771450" },
                { "29.3650", "-94.7800", "8771328" },
                { "29.3833", "-94.8833", "TEC4513" },
                { "29.4800", "-94.9183", "8771013" },
                { "29.5633", "-95.0667", "8770933" },
                { "29.6817", "-94.9850", "8770613" },
                { "29.7649", "-95.0789", "8770733" },
                { "29.7262", "-95.2658", "8770777" },
                { "29.7133", "-94.6900", "8770559" },
                { "29.6800", "-94.8683", "8770625" },
                { "29.7400", "-94.8317", "8770557" },
                { "29.5156", "-94.5106", "8770971" },
                { "29.5947", "-94.3903", "8770808" },
                { "29.5167", "-94.4833", "TEC4525" },
                { "29.3026", "-94.8971", "8771486" },
                { "29.2000", "-94.9850", "8771721" },
                { "29.1667", "-95.1250", "8771801" },
                { "29.0810", "-95.1313", "8771972" },
                { "29.0417", "-95.1750", "8772132" },
                { "29.2853", "-94.7894", "8771510" },
                { "28.7714", "-95.6172", "8772985" },
                { "28.9357", "-95.2942", "8772471" },
                { "28.9483", "-95.3083", "8772440" },
                { "28.7101", "-95.9140", "8773146" },
                { "28.4269", "-96.3301", "8773767" },
                { "28.4069", "-96.7124", "8773037" },
                { "28.2283", "-96.7950", "8774230" },
                { "28.1144", "-97.0244", "8774513" },
                { "28.4459", "-96.3956", "8773701" },
                { "28.6406", "-96.6098", "8773259" },
                { "27.8328", "-97.4859", "8775244" },
                { "27.8366", "-97.0391", "8775241" },
                { "27.8397", "-97.0725", "8775237" },
                { "27.5800", "-97.2167", "8775870" },
                { "27.8149", "-97.3892", "8775296" },
                { "27.6333", "-97.2367", "8775792" },
                { "26.0674", "-97.1548", "8779749" },
                { "26.0683", "-97.1567", "8779750" },
                { "26.0783", "-97.1700", "8779724" },
                { "26.0717", "-97.1917", "8779739" },
                { "26.0612", "-97.2155", "8779770" },
                { "26.0517", "-97.1817", "8779768" },
            };

            // Create simple marker symbol for tide predictions
            SimpleMarkerSymbol tideMarker = new SimpleMarkerSymbol()
            {
                Color = Color.Blue,
                Size  = 10,
                Style = SimpleMarkerSymbolStyle.Circle
            };

            // create graphics overlay
            GraphicsOverlay tideLayer = new GraphicsOverlay();

            // create graphics for each tide location
            int tideLength = tidePrediction.Length / 3;

            for (int i = 0; i < tideLength; i++)
            {
                string   latLon      = tidePrediction[i, 0].ToString() + " " + tidePrediction[i, 1].ToString();
                MapPoint tide        = CoordinateFormatter.FromLatitudeLongitude(latLon, SpatialReferences.Wgs84);
                Graphic  tideGraphic = new Graphic(tide, tideMarker);
                tideLayer.Graphics.Add(tideGraphic);
            }

            // add layer to map
            _mapView.GraphicsOverlays.Add(tideLayer);

            // method for when tide point is clicked
            _mapView.GeoViewTapped += async(s, e) =>
            {
                try
                {
                    //identify tide overlay
                    IdentifyGraphicsOverlayResult identifyResults = await _mapView.IdentifyGraphicsOverlayAsync(
                        tideLayer,
                        e.Position,
                        10d,
                        false,
                        1

                        );

                    // get user tap point
                    Geometry          myGeo      = GeometryEngine.Project(e.Location, SpatialReferences.Wgs84);
                    MapPoint          projection = (MapPoint)myGeo;
                    CalloutDefinition myCallout;
                    int latitidueFinal = 0;

                    // compare user point to map points
                    if (identifyResults.Graphics.Count > 0)
                    {
                        string description = " ";
                        for (int i = 0; i < tideLength; i++)
                        {
                            for (int j = 1; j < 3; j++)
                            {
                                double latNDBC        = Convert.ToDouble(tidePrediction[i, 0]);
                                double latNDBCRounded = Math.Round(latNDBC, 1);

                                double latClick        = Convert.ToDouble(projection.Y);
                                double latClickRounded = Math.Round(latClick, 1);

                                double lowerLat = latClickRounded - .1;
                                double upperLat = latClickRounded + .1;

                                double lonNDBC        = Convert.ToDouble(tidePrediction[i, 1]);
                                double lonNDBCRounded = Math.Round(lonNDBC, 1);

                                double lonClick        = Convert.ToDouble(projection.X);
                                double lonClickRounded = Math.Round(lonClick, 1);

                                double lowerLon = lonClickRounded - .1;
                                double upperLon = lonClickRounded + .1;



                                if (lowerLat <= latNDBCRounded && upperLat >= latNDBCRounded && lowerLon <= lonNDBCRounded && upperLon >= lonNDBCRounded)
                                {
                                    latitidueFinal = i;
                                }
                            }
                        }



                        // create callout
                        string title             = tidePrediction[latitidueFinal, 2];
                        string latLonDescription = "Latitude: " + tidePrediction[latitidueFinal, 0] + "\n" + "Longitude: " + tidePrediction[latitidueFinal, 1] + "\n";
                        string url = "https://tidesandcurrents.noaa.gov/noaatidepredictions.html?id=" + tidePrediction[latitidueFinal, 2];

                        description += latLonDescription;


                        myCallout = new CalloutDefinition(title, description);
                        _mapView.ShowCalloutAt(e.Location, myCallout);
                    }
                    // if user does not click on a tide point, get rid of any existing callouts
                    else
                    {
                        _mapView.DismissCallout();
                    }
                }
                catch (Exception ex)
                {
                }
            };
        }
        public static CalloutDefinition ConvertFrom(Controls.CalloutDefinition definition)
        {
            CalloutDefinition nativeDefinition = new CalloutDefinition(definition.Title, definition.Message);

            return(nativeDefinition);
        }