public CoordinateViewModel Create(GeoCodingResult result) { return(new CoordinateViewModel { Latitude = result.Coordinate.Latitude, Longitude = result.Coordinate.Longitude, Description = result.GetDescription() }); }
public static string GetDescription(this GeoCodingResult result) { var sb = new StringBuilder(); if (!string.IsNullOrEmpty(result.City)) { sb.Append(result.City); if (!string.IsNullOrEmpty(result.State)) { sb.Append(", "); } } sb.Append(result.State); return(sb.ToString()); }
private async void GeoCodeTest() { GeoCodingOption rgo = new GeoCodingOption(); rgo.Address = "北京市朝阳区望京阜通东大街方恒国际中心"; GeoCodingResult rgcs = await GeoCode.AddressToGeoCodeWithOption(rgo); this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { if (rgcs.Erro == null && rgcs.GeoCodingList != null) { IEnumerable <GeoPOI> pois = rgcs.GeoCodingList; int i = 0; foreach (GeoPOI poi in pois) { i++; ATip tip = new ATip(); tip.Title = poi.Name; tip.ContentText = poi.Address; AMarker marker = new AMarker(); marker.LngLat = new ALngLat(poi.X, poi.Y); marker.TipFrameworkElement = tip; map.Children.Add(marker); marker.OpenTip(); map.SetZoomAndCenter(18, marker.LngLat); } Debug.WriteLine(rgcs); } else { MessageDialog msd = new MessageDialog(rgcs.Erro.Message); this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { msd.ShowAsync(); }); } }); }