public partial class MainPage : UserControl { Locator _locatorTask, _locatorTask2; GraphicsLayer _candidateGraphicsLayer; private static ESRI.ArcGIS.Client.Projection.WebMercator _mercator = new ESRI.ArcGIS.Client.Projection.WebMercator(); public MainPage() { InitializeComponent(); _candidateGraphicsLayer = MyMap.Layers["CandidateGraphicsLayer"] as GraphicsLayer; } private void FindAddressButton_Click(object sender, RoutedEventArgs e) { _candidateGraphicsLayer.ClearGraphics(); CandidateListBox.Items.Clear(); _locatorTask = new Locator("http://gismaps.pagnet.org/ArcGIS/rest/services/PAGAddressLocator2/GeocodeServer"); _locatorTask.AddressToLocationsCompleted += LocatorTask_AddressToLocationsCompleted; _locatorTask.Failed += LocatorTask_Failed; AddressToLocationsParameters addressParams1 = new AddressToLocationsParameters() { OutSpatialReference = MyMap.SpatialReference }; Dictionary<string, string> address1 = addressParams1.Address; if (!string.IsNullOrEmpty(InputAddress1.Text)) address1.Add("Street", InputAddress1.Text); if (!string.IsNullOrEmpty(City1.Text)) address1.Add("City", City1.Text); if (!string.IsNullOrEmpty(State1.Text)) address1.Add("State", State1.Text); if (!string.IsNullOrEmpty(Zip1.Text)) address1.Add("ZIP", Zip1.Text); _locatorTask.AddressToLocationsAsync(addressParams1); { _locatorTask2 = new Locator("http://gismaps.pagnet.org/ArcGIS/rest/services/PAGAddressLocator2/GeocodeServer"); _locatorTask2.AddressToLocationsCompleted += LocatorTask_AddressToLocationsCompleted; _locatorTask2.Failed += LocatorTask_Failed; AddressToLocationsParameters addressParams2 = new AddressToLocationsParameters() { OutSpatialReference = MyMap.SpatialReference }; Dictionary<string, string> address2 = addressParams2.Address; if (!string.IsNullOrEmpty(InputAddress2.Text)) address2.Add("Street", InputAddress2.Text); if (!string.IsNullOrEmpty(City2.Text)) address2.Add("City", City2.Text); if (!string.IsNullOrEmpty(State2.Text)) address2.Add("State", State2.Text); if (!string.IsNullOrEmpty(Zip2.Text)) address2.Add("ZIP", Zip2.Text); _locatorTask2.AddressToLocationsAsync(addressParams2); } }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.