ReverseGeolocation and reverseGeolocationAsync

RobertDalyRobertDaly USMember ✭✭

Hi All,
Can anyone provide me with the mechanism to be used to make use of these functions? I am almost at my wits end in trying to use this. I have searched and seen many ways using objective-c but I haven't been able to locate any samples anywhere using C# with xamarin. I have successfully been able to get latitude, longitude, and compass headings with no problem. But it appears inordinately difficult to get the human readable conversion of the latitude and longitude. I am probably missing something very simple (or complex!), but I can't seem to properly set up the CLGeocodeCompletionHandler.
Any assistance would be most appreciated. Thanking all in advance.

Posts

  • LarryOBrienLarryOBrien USXamarin Team Xamurai

    difficult to get the human readable conversion of the latitude and longitude.

    Do you mean conversion from decimal lat/long to Degree/Minute/Second?

  • RobertDalyRobertDaly USMember ✭✭

    Thanks for the reply. No, that I have already done. It is trying to get the actual location of the coordinates, i.e. 40° 48' 25", -73° 08' 31" is Ronkonkoma, NY. This can be obtained using the ReverseGeolocation and/or ReverseGeolocationAsync methods, but I can't seem to properly code these with C#.

  • RobertDalyRobertDaly USMember ✭✭

    Thank you sezamus, I did use this as a guide, it was very informative, but it doesn't make use of the ReverseGeolocation and reverseGeolocationAsync. I successfully adopted all of the things in the sample, but couldn't find anything related to obtaining the ReverseGeoLocation. Any other ideas?

  • sezamuzsezamuz BSMember ✭✭
    edited October 2013
            static public void UpdateLocation (IMainScreen ms, CLLocation newLocation)
            {
                ms.LblAltitude.Text = newLocation.Altitude.ToString () + " meters";
                ms.LblLongitude.Text = newLocation.Coordinate.Longitude.ToString () + "º";
                ms.LblLatitude.Text = newLocation.Coordinate.Latitude.ToString () + "º";
                ms.LblCourse.Text = newLocation.Course.ToString () + "º";
                ms.LblSpeed.Text = newLocation.Speed.ToString () + " meters/s";
    
                var geocoder = new CLGeocoder ();
                geocoder.ReverseGeocodeLocation (newLocation, (CLPlacemark[] placemarks, NSError error) => {
                    if ((placemarks != null)&&(placemarks.Length>0)) ms.LblDistanceToParis.Text = placemarks[0].AdministrativeArea;
                } );
    
                // get the distance from here to paris
                ms.LblDistanceToParis.Text = (newLocation.DistanceFrom(new CLLocation(41.123, 7.632)) / 1000).ToString() + " km";
            }
    

    ReverseGeocodeLocation here present

    also in sample http://docs.xamarin.com/recipes/ios/content_controls/map_view/display_device_location/ present

  • RobertDalyRobertDaly USMember ✭✭

    Can't thank you enough! If you are ever visit Long Island let me know. I owe you one!

    Thanks again!

  • sezamuzsezamuz BSMember ✭✭

    tnx )

Sign In or Register to comment.