This example allows you to enter an address, then displays the location of matching addresses. This is commonly known as geocoding. In the ArcGIS JavaScript API, you use theLocator class to perform geocoding.
這個例子允許你輸入一個地址,然後展現匹配的位置。這通常被叫做地理編碼。
The Locator constructor requires the URL of an ArcGIS Server geocode service. A geocode service represents an address locator that has been made available on the server. This example uses the ESRI_Geocode_USA service on the ESRI sample server. You can use the Services Directory to discover the URL to your own geocode service.
Locator建構函式需要ArcGIS Server的geocode service的URL。geocode service代表一個在伺服器上可用的位置定位器。
When the user clicks the Locate button, the locate function is called. This function parses the address text entered by the user into a four-item array. The four items (address, city, state, and zip) correspond to the address fields defined in the locator. You can discover these address fields by looking up the geocode service in the Services Directory. For example, this page shows the four address fields for the geocode service used in this example.
當使用者點擊Locate按鈕,定位函數被調用。這個個函數解析使用者輸入的位置文本為四元素的數組。這個四個元素(address,city,state和zip)匹配locator中定義的欄位。你可以發現這些地址欄位通過查看在服務類別目錄中的geocode service
The locator begins searching for matches when the addressToLocations method is called:
locator.addressToLocations(address);
Reverse geocoding determines the address of a given point on a map. This sample shows how to do reverse geocoding with the ArcGIS JavaScript API.
反地理編碼決定地圖上一個給定的點的地址。