For those encountering this issue in the future I realized the following solution.I'm sure there's a more elegant way, but this seems to be doing the trick.The main thing I realized was that I needed to create a new _locatorTask (i.e. _locatorTask2) AND to set it as a Locator resource ( i.e. Locator _locatorTask, _locatorTask2; ).Another item to note that is different from the SL sample is to move the GraphicsLayer.ClearGraphics code to immediately under the FindAddressButton_Click event. Both geocode tasks were working but only one graphic was showing because the first one was getting cleared when the ClearGraphics code snippet was in its original place. 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);
}
}