public static LocationTooltipInfo ReverseLocate(double x, double y) { try { var xlocate = new XLocateServiceReference.XLocateWSClient(); xlocate.ClientCredentials.UserName.UserName = "******"; xlocate.ClientCredentials.UserName.Password = token; var result = xlocate.findLocation( new XLocateServiceReference.Location { coordinate = new XLocateServiceReference.Point { point = new XLocateServiceReference.PlainPoint { x = x, y = y } } }, null, null, new[] { XLocateServiceReference.ResultField.XYN }, new XLocateServiceReference.CallerContext { wrappedProperties = new[] { new XLocateServiceReference.CallerContextProperty { key = "CoordFormat", value = "OG_GEODECIMAL" } } } ); if (result.wrappedResultList == null || result.wrappedResultList.Length < 1) { return(null); } var address = result.wrappedResultList[0]; return(new LocationTooltipInfo { Country = (address.country + " " + address.state).Trim(), City = (address.postCode + " " + address.city).Trim(), Street = (address.street + " " + address.houseNumber).Trim() }); } catch (WebException) { return(null); } }
private void Map_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (e.LeftButton != MouseButtonState.Pressed) { return; } var wgs = Map.MouseToGeo(e); var xlocate = new XLocateServiceReference.XLocateWSClient(); xlocate.ClientCredentials.UserName.UserName = "******"; xlocate.ClientCredentials.UserName.Password = token; var result = xlocate.findLocation( new XLocateServiceReference.Location { coordinate = new XLocateServiceReference.Point { point = new XLocateServiceReference.PlainPoint { x = wgs.X, y = wgs.Y } } }, null, null, new[] { XLocateServiceReference.ResultField.XYN }, new XLocateServiceReference.CallerContext { wrappedProperties = new[] { new XLocateServiceReference.CallerContextProperty { key = "CoordFormat", value = "OG_GEODECIMAL" } } } ); if (result.wrappedResultList != null && result.wrappedResultList.Length > 0 && result.wrappedResultList[0].wrappedAdditionalFields.Length == 1) { xynLayer.SetXYN(result.wrappedResultList[0].wrappedAdditionalFields[0].value); } else { xynLayer.SetXYN(null); } }