Thanks for the response!I have gotten the map now to draw the icon correctly, however it will not calcuate the proper address down to a high resolution than the City/State/ZIP. The address field entries seems to make no difference.Here is the code.private void FindAddressButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
Locator locatorTask = new Locator("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
"Locators/ESRI_Geocode_USA/GeocodeServer");
locatorTask.AddressToLocationsCompleted += LocatorTask_AddressToLocationsCompleted;
AddressToLocationsParameters addressParameters = new AddressToLocationsParameters();
Dictionary<string, string> address = addressParameters.Address;
address.Add("Address", Address.Text);
address.Add("City", City.Text);
address.Add("State", State.Text);
address.Add("Zip", Zip.Text);
locatorTask.AddressToLocationsAsync(addressParameters);
}
private void LocatorTask_AddressToLocationsCompleted(object sender, ESRI.ArcGIS.Client.Tasks.AddressToLocationsEventArgs args)
{
if (args.Results.Count > 0)
{
// Get the best match
AddressCandidate bestCandidate = args.Results[0];
foreach (AddressCandidate candidate in args.Results)
bestCandidate = (candidate.Score > bestCandidate.Score) ? candidate : bestCandidate;
Graphic graphic = new Graphic()
{
Symbol = AddressToLocationSymbol,
Geometry = bestCandidate.Location
};
graphic.Attributes.Add("Address", bestCandidate.Address);
graphic.Attributes.Add("City", bestCandidate.Address);
string latLon = String.Format("{0}, {1}", bestCandidate.Location.X, bestCandidate.Location.Y);
graphic.Attributes.Add("LatLon", latLon);
GraphicsLayer graphicsLayer = Map.Layers["AddressToLocationGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
graphicsLayer.Graphics.Add(graphic);
}
else
{
MessageBox.Show("No results found");
As you can see, it is pretty much the exact code found in the guide above, and it also uses the ESRI geocoder. So i thought maybe the error is in the xaml code. However I cant seem to find anything in there either that looks awry.<StackPanel Margin="27,18,0,8" HorizontalAlignment="Left" >
<TextBlock Text="Click Find to locate an address" HorizontalAlignment="Center"
Margin="0,0,0,5" Foreground="Black" FontStyle="Italic" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
<TextBlock Text="Address: " Foreground="Black" />
<TextBox x:Name="Address" Text="510 W 9th" Width="125" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
<TextBlock Text="City: " Foreground="Black" />
<TextBox x:Name="City" Text="Georgetown" Width="125" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
<TextBlock Text="State: " Foreground="Black" />
<TextBox x:Name="State" Text="TX" Width="125"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
<TextBlock Text="Zip: " Foreground="Black" />
<TextBox x:Name="Zip" Text="" Width="125" />
</StackPanel>
<Button x:Name="FindAddressButton" Content="Find" Width="176" HorizontalAlignment="Center" Margin="0,5,0,0" Click="FindAddressButton_Click" />
<Line HorizontalAlignment="Center" X1="0" Y1="10" X2="180" Y2="10" StrokeThickness="1" Stroke="White" />
I am thinking that perhaps it has something to do with which results to draw, and as a result it is not drawing the correct number of points. OR the address field is messed up some how and is not putting in correct results.However, when I enter the exact same address here , it pulls up the correct results.Do you know what could be making this happen?Thanks again!