New pricing changes went into effect on July 16, 2018. For more information, check out the Guide for Existing Users.

Geocoder

Geocoder class

google.maps.Geocoder class

A service for converting between an address and a LatLng.

Constructor
Geocoder
Geocoder()
Parameters:  None
Creates a new instance of a Geocoder that sends geocode requests to Google servers.
Methods
geocode
geocode(request, callback)
Parameters: 
Return Value:  None
Geocode a request.

GeocoderRequest interface

google.maps.GeocoderRequest interface

The specification for a geocoding request to be sent to the Geocoder.

Properties
address
Type:  string
Address to geocode. One, and only one, of address, location and placeId must be supplied.
bounds
LatLngBounds within which to search. Optional.
componentRestrictions
Components are used to restrict results to a specific area. A filter consists of one or more of: route, locality, administrativeArea, postalCode, country. Only the results that match all the filters will be returned. Filter values support the same methods of spelling correction and partial matching as other geocoding requests. Optional.
location
LatLng (or LatLngLiteral) for which to search. The geocoder performs a reverse geocode. See Reverse Geocoding for more information. One, and only one, of address, location and placeId must be supplied.
placeId
Type:  string
The place ID associated with the location. Place IDs uniquely identify a place in the Google Places database and on Google Maps. Learn more about place IDs in the Places API developer guide. The geocoder performs a reverse geocode. See Reverse Geocoding for more information. One, and only one, of address, location and placeId must be supplied.
region
Type:  string
Country code used to bias the search, specified as a Unicode region subtag / CLDR identifier. Optional.

GeocoderComponentRestrictions interface

google.maps.GeocoderComponentRestrictions interface

GeocoderComponentRestrictions represents a set of filters that resolve to a specific area. For details on how this works, see Geocoding Component Filtering.

Properties
administrativeArea
Type:  string
Matches all the administrative_area levels. Optional.
country
Type:  string
Matches a country name or a two letter ISO 3166-1 country code. Optional.
locality
Type:  string
Matches against both locality and sublocality types. Optional.
postalCode
Type:  string
Matches postal_code and postal_code_prefix. Optional.
route
Type:  string
Matches the long or short name of a route. Optional.

GeocoderStatus constants

google.maps.GeocoderStatus constants

The status returned by the Geocoder on the completion of a call to geocode(). Specify these by value, or by using the constant's name. For example, 'OK' or google.maps.GeocoderStatus.OK.

Constants
ERROR There was a problem contacting the Google servers.
INVALID_REQUEST This GeocoderRequest was invalid.
OK The response contains a valid GeocoderResponse.
OVER_QUERY_LIMIT The webpage has gone over the requests limit in too short a period of time.
REQUEST_DENIED The webpage is not allowed to use the geocoder.
UNKNOWN_ERROR A geocoding request could not be processed due to a server error. The request may succeed if you try again.
ZERO_RESULTS No result was found for this GeocoderRequest.

GeocoderResult interface

google.maps.GeocoderResult interface

A single geocoder result retrieved from the geocode server. A geocode request may return multiple result objects. Note that though this result is "JSON-like," it is not strictly JSON, as it indirectly includes a LatLng object.

Properties
address_components
An array of GeocoderAddressComponents
formatted_address
Type:  string
A string containing the human-readable address of this location.
geometry
A GeocoderGeometry object
partial_match
Type:  boolean
Whether the geocoder did not return an exact match for the original request, though it was able to match part of the requested address.
place_id
Type:  string
The place ID associated with the location. Place IDs uniquely identify a place in the Google Places database and on Google Maps. Learn more about Place IDs in the Places API developer guide.
postcode_localities
Type:  Array<string>
An array of strings denoting all the localities contained in a postal code. This is only present when the result is a postal code that contains multiple localities. This array can contain up to 10 localities.
types
Type:  Array<string>
An array of strings denoting the type of the returned geocoded element. For a list of possible strings, refer to the Address Component Types section of the Developer's Guide.

GeocoderAddressComponent interface

google.maps.GeocoderAddressComponent interface

A single address component within a GeocoderResult. A full address may consist of multiple address components.

Properties
long_name
Type:  string
The full text of the address component
short_name
Type:  string
The abbreviated, short text of the given address component
types
Type:  Array<string>
An array of strings denoting the type of this address component. A list of valid types can be found here

GeocoderGeometry interface

google.maps.GeocoderGeometry interface

Geometry information about this GeocoderResult

Properties
bounds
Type:  LatLngBounds
The precise bounds of this GeocoderResult, if applicable
location
Type:  LatLng
The latitude/longitude coordinates of this result
location_type
The type of location returned in location
viewport
Type:  LatLngBounds
The bounds of the recommended viewport for displaying this GeocoderResult

GeocoderLocationType constants

google.maps.GeocoderLocationType constants

Describes the type of location returned from a geocode. Specify these by value, or by using the constant's name. For example, 'ROOFTOP' or google.maps.GeocoderLocationType.ROOFTOP.

Constants
APPROXIMATE The returned result is approximate.
GEOMETRIC_CENTER The returned result is the geometric center of a result such a line (e.g. street) or polygon (region).
RANGE_INTERPOLATED The returned result reflects an approximation (usually on a road) interpolated between two precise points (such as intersections). Interpolated results are generally returned when rooftop geocodes are unavailable for a street address.
ROOFTOP The returned result reflects a precise geocode.

Envoyer des commentaires concernant…

Maps JavaScript API
Besoin d'aide ? Consultez notre page d'assistance.