Class: VEGeocoder

Description

Class added v1.4.
dojo.require("esri.virtualearth.VEGeocoder");

Bing Maps geocoder. See Locator for geocoding with ArcGIS Server locators. If you are working with the 1.x version of the ArcGIS JavaScript API, you will need to use tokens, view the information here on setting up a Virtual Earth token page.

Samples

Search for samples that use this class.  

Class hierarchy

esri.virtualearth.VEGeocoder

Constructor

Constructor Description
esri.virtualearth.VEGeocoder(options) Creates a new VEGeocoder object.

Properties

Property Type Description
culture String Specifies the culture in which to return results. The default value is "en-US". For a list of supported cultures, see http://msdn.microsoft.com/en-us/library/cc981048.aspx.

Methods

Method Return Value Description
addressToLocations(query, callback?, errback?) dojo.Deferred Sends a geocode request to Bing Maps to find candidates for a single address specified in the query argument. On completion, the onAddressToLocationsComplete event is fired and the optional callback function is invoked.
setCulture(culture) none Sets the culture in which to return results.

Events

Event Description
onAddressToLocationsComplete(geocodeResults) Fires when VEGeocode.addressToLocation() has completed. The result is an array of VEGeocodeResult. This is the same signature returned if the optional callback is specified.
onError(error) Fires when an error occurs when executing the task.
Constructor Detail

esri.virtualearth.VEGeocoder(options)

Creates a new VEGeocoder object.
Parameters:
<Object> options Required See options list for parameters.
Options:
<String> bingMapsKey Key used to access Bing Maps maps. View the Getting start with Bing Maps help topic for more details.
<String> culture Specifies the culture in which to return results. The default value is "en-US". For a list of supported cultures, see http://msdn.microsoft.com/en-us/library/cc981048.aspx.
Code snippets:
veGeocoder = new esri.virtualearth.VEGeocoder({
 bingMapsKey:'Al0VE_jsmagxk4LFghXGlK5JSHfC0tk-eHRubZv_eMYm6wzgQaStYks8g-wWcgk3'
});
Properties Detail

<String> culture

Specifies the culture in which to return results. The default value is "en-US". For a list of supported cultures, see http://msdn.microsoft.com/en-us/library/cc981048.aspx.
Default value: en-US
See also:
setCulture  
Methods Detail

addressToLocations(query, callback?, errback?)

Sends a geocode request to Bing Maps to find candidates for a single address specified in the query argument. On completion, the onAddressToLocationsComplete event is fired and the optional callback function is invoked.
Return value: dojo.Deferred
Input Parameters:
<String> query Required The address to locate.
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onAddressToLocationsComplete event.
<Function> errback Optional An error object is returned if an error occurs during task execution.
Code snippets:
var query = "380 New York St, Redlands, CA, 92373";
veGeocoder.addressToLocations(query);

setCulture(culture)

Sets the culture in which to return results.
Return value: none
Input Parameters:
<String> culture Required The culture value. The default value is "en-US". For a list of supported cultures, see http://msdn.microsoft.com/en-us/library/cc981048.aspx.
See also:
culture  

Events Detail

onAddressToLocationsComplete(geocodeResults)

Fires when VEGeocode.addressToLocation() has completed. The result is an array of VEGeocodeResult. This is the same signature returned if the optional callback is specified.
Arguments:
<VEGeocodeResult[]> geocodeResults Contains an array of candidates that match the given address as well as their scores.
Code snippets:
dojo.connect(veGeocoder, "onAddressToLocationsComplete", function(geocodeResults) {
  var pointMeters = esri.geometry.geographicToWebMercator(geocodeResults[0].location);
  var pointSymbol = new esri.symbol.SimpleMarkerSymbol().setSize(15).setColor(new dojo.Color("blue"));
  var locationGraphic = new esri.Graphic(pointMeters,pointSymbol);
  map.graphics.add(locationGraphic);
});
See also:
addressToLocations  

onError(error)

Fires when an error occurs when executing the task.
Arguments:
<Error> error Error message returned in a JavaScript error object.