Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

GeocodeServiceClient.Geocode Method

This documentation is no longer available on MSDN. It is available as a CHM or PDF download. For the newest Geocoding, Imagery, Routing and Traffic services, see the Bing Maps REST Services

Finds a geographic location based on a request that may include the address, place, or entity type names to find.

Public Function Geocode(ByVal request As GeocodeRequest) As GeocodeResponse


A GeocodeRequest object that contains the header and parameter information for the service operation.

Private Sub MakeGeocodeRequest()

Dim Results As String
' Set a Bing Maps key before making a request
Dim key = "Bing Maps Key"

Dim geocodeRequest As New GeocodeService.GeocodeRequest()

' Set the credentials using a valid Bing Maps Key
geocodeRequest.Credentials = _
New GeocodeService.Credentials() With {.ApplicationId = key}

' Set the full address query
geocodeRequest.Query = "1 Microsoft Way, Redmond, WA"

' Set the options to only return high confidence results
Dim filters() As GeocodeService.ConfidenceFilter = _
{New GeocodeService.ConfidenceFilter() _
With {.MinimumConfidence = GeocodeService.Confidence.High}}

Dim geocodeOptions As New GeocodeService.GeocodeOptions() _
With {.Filters = filters}

geocodeRequest.Options = geocodeOptions

' Make the geocode request
Dim geocodeServiceInstance As New GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService")
Dim geocodeResponse = geocodeServiceInstance.Geocode(geocodeRequest)

' Use the results in your application.
Results = geocodeResponse.Results(0).DisplayName

Catch ex As Exception
Results = "An exception occurred: " & ex.Message

End Try

End Sub

© 2015 Microsoft