private void GeoMap_Tap(object sender, GestureEventArgs e) { var tapPosition = e.GetPosition((UIElement)e.OriginalSource); var geoCoordinate = GeoMap.ViewportPointToLocation(tapPosition); GoogleMapsSimpleService gmService = new GoogleMapsSimpleService(); var geoLocation = new GeoLocation(geoCoordinate.Latitude, geoCoordinate.Longitude); //set pushpin Pushpin pin = locationPushPin; pin.Location = geoCoordinate; pin.Content = Address; NavigateToMap(geoCoordinate); //set current latitude and longitude this.Latitude = geoCoordinate.Latitude; this.Longitude = geoCoordinate.Longitude; //find address gmService.GetAddressByGeoLocation(geoLocation, (address)=> { Dispatcher.BeginInvoke(()=> { string resultAddress = address.Substring(0,Math.Min(address.Length,254)); Address = resultAddress; locationPushPin.Content = resultAddress; }); }); }
public void OnGetGeoLocationByAddress(GeoLocation geoLocation) { Dispatcher.BeginInvoke( () => { if (geoLocation == null) { MessageBox.Show("Address not found!"); } GpsLocationRetrievalProgress.IsEnabled = false; //PositionTextBox.Text = geoLocation.ToString(); Latitude = geoLocation.Latitude; Longitude = geoLocation.Longitude; GeoCoordinate geoCoordinate = new GeoCoordinate(geoLocation.Latitude, geoLocation.Longitude); var pinPoint = GeoMap.LocationToViewportPoint(geoCoordinate); Pushpin pin = locationPushPin; pin.Location = geoCoordinate; pin.Content = Address; NavigateToMap(geoCoordinate); } ); }