private void OnGeoLocatorSearchComplete(ResultsGeoLocatorEventArgs e) { if (resultsGeoLocatorHandler != null) resultsGeoLocatorHandler(this, e); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void locatorTask_LocationToAddressCompleted(object sender, AddressEventArgs e) { try { locatorTask.LocationToAddressCompleted -= locatorTask_LocationToAddressCompleted; Address address = e.Address; Dictionary<string, object> attributes = e.Address.Attributes; IList<GeoLocatorDetail> result = new List<GeoLocatorDetail>(); WebMercator webMercator = new WebMercator(); result.Add(new GeoLocatorDetail() { Location = address.Location, Match = 100.0, Title = string.Format("{0} {1},{2}", attributes["Address"], attributes["City"], attributes["Postcode"]), Attributes = attributes }); ResultsGeoLocatorEventArgs resultEventArgs = new ResultsGeoLocatorEventArgs(result); OnGeoLocatorSearchComplete(resultEventArgs); } catch (Exception ex) { messageBoxCustom.Show(String.Format("locatorTask_LocationToAddressCompleted /{0}", ex.Message), GisTexts.SevereError, MessageBoxCustomEnum.MessageBoxButtonCustom.Ok); } }
void locatorTask_Failed(object sender, TaskFailedEventArgs e) { try { locatorTask.AddressToLocationsCompleted -= locatorTask_AddressToLocationsCompleted; IList<GeoLocatorDetail> result = new List<GeoLocatorDetail>(); result.Add(new GeoLocatorDetail() { Location = null, Match = 0.0, Title = e.Error.Message }); if (e.Error.InnerException != null) result[0].Title = String.Format("{0}-{1}", result[0].Title, e.Error.InnerException.Message); ResultsGeoLocatorEventArgs resultEventArgs = new ResultsGeoLocatorEventArgs(result); OnGeoLocatorSearchComplete(resultEventArgs); } catch (Exception ex) { messageBoxCustom.Show(String.Format("locatorTask_Failed /{0}", ex.Message), GisTexts.SevereError, MessageBoxCustomEnum.MessageBoxButtonCustom.Ok); } }
void locatorTask_AddressToLocationsCompleted(object sender, AddressToLocationsEventArgs e) { try { locatorTask.AddressToLocationsCompleted -= locatorTask_AddressToLocationsCompleted; IList<GeoLocatorDetail> result = new List<GeoLocatorDetail>(); WebMercator webMercator = new WebMercator(); if (e.Results.Count > 0) { foreach (var item in e.Results) { result.Add(new GeoLocatorDetail() { Location = webMercator.FromGeographic(item.Location) as MapPoint, Match = System.Convert.ToDouble(item.Score), Title = item.Address }); } } else { } ResultsGeoLocatorEventArgs resultEventArgs = new ResultsGeoLocatorEventArgs(result); OnGeoLocatorSearchComplete(resultEventArgs); } catch (Exception ex) { messageBoxCustom.Show(String.Format("locatorTask_AddressToLocationsCompleted /{0}", ex.Message), GisTexts.SevereError, MessageBoxCustomEnum.MessageBoxButtonCustom.Ok); } }
private void HandleGeolocatorResults(object sender, ResultsGeoLocatorEventArgs geoLocatorResults) { // if (geoLocatorResults.result != null && geoLocatorResults.result.Count > 0) { ResultInfoEventArgs e = new ResultInfoEventArgs(currentPosition, geoLocatorResults.result[0].Location, false) { Attributes = geoLocatorResults.result[0].Attributes, LayerId = string.Empty }; if (locationInputViewModel == null || locationInputViewModel.LocationsSelected.Count == 0) DisplayInfoResults(e); else { // Transfer the contents of the result to the stops list locationInputViewModel.StopsVisibility = Visibility.Visible; locationInputViewModel.RouteDirectionsVisibility = Visibility.Collapsed; locationInputViewModel.SelectionVisibility = Visibility.Collapsed; locationInputViewModel.LocationsSelected.Add(new GeoLocatorDetail() { Attributes = geoLocatorResults.result[0].Attributes, Location = geoLocatorResults.result[0].Location, Match = geoLocatorResults.result[0].Match, Title = geoLocatorResults.result[0].Title }); gisOperations.GetSelectLayer().Graphics.Add(new Graphic() { Geometry = geoLocatorResults.result[0].Location, Symbol = geoLocator.GetLocationMarker(), Selected = true }); locationInputViewModel.RefreshStops(); locationInputViewModel.Zoom2Stops(); } } }
private void HandleGeolocatorResults(object sender, ResultsGeoLocatorEventArgs e) { if (e.result != null) { this.LocationResults.Clear(); foreach (var item in e.result) this.LocationResults.Add(item); } }