private void FindAddressButton_Click(object sender, RoutedEventArgs e) { ExecuteFindAddress(); } private void ExecuteFindAddress() { _locatorTask = new Locator("http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Streets_US_10/GeocodeServer"); _locatorTask.AddressToLocationsCompleted += LocatorTask_AddressToLocationsCompleted; _locatorTask.Failed += LocatorTask_Failed; AddressToLocationsParameters addressParams = new AddressToLocationsParameters() { OutSpatialReference = MyMap.SpatialReference }; Dictionary<string, string> address = addressParams.Address; if (!string.IsNullOrEmpty(InputAddress.Text)) address.Add("Street", InputAddress.Text); if (!string.IsNullOrEmpty(City.Text)) address.Add("City", City.Text); if (!string.IsNullOrEmpty(State.Text)) address.Add("State", State.Text); if (!string.IsNullOrEmpty(Zip.Text)) address.Add("ZIP", Zip.Text); _locatorTask.AddressToLocationsAsync(addressParams); } private void InputAddress_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.Enter) { ExecuteFindAddress(); } }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.