Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to replicate this sample on my web map. I have been able to build it successfully as-is within VS 2010. However, I run into some issues when I try to get it to work with my services. I've successfully been able to display my map service, but I’m getting snagged up on the geocoding part. My geocode service is published and working fine (tested it within REST). Also, a ClientAccessPolicy.XML is on our server so I don't believe there are access issues.

On the xaml side of things, I've removed all but the Address stackpanel. I think my problems are arising on the C# side. This is the bit of code I believe is giving me troubles:

   private void FindAddressButton_Click(object sender, RoutedEventArgs e)
        Locator locatorTask = new Locator("" +
        locatorTask.AddressToLocationsCompleted += LocatorTask_AddressToLocationsCompleted;
        locatorTask.Failed += LocatorTask_Failed;
        AddressToLocationsParameters addressParams = new AddressToLocationsParameters();
        Dictionary<string, string> address = addressParams.Address;           

        if (!string.IsNullOrEmpty(State.Text))
            address.Add("Address", Address.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);

        if (addressParams.Address.Count == 0)
          GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
          if (graphicsLayer !=null)
          CandidateScrollViewer.Content = null;
          CandidatePanelGrid.Visibility = Visibility.Collapsed;
          MessageBox.Show("No address field entered.");


I've replaced the GeocodeServer URL with my service. A little further down are IF statements that deal with parameters and I’m not sure how to handle. I initially tried to remove all but the first IF statements, but I get errors when I go to interact with the map (it builds successfully). I'm not a programmer so I'm not sure how involved it would be make the manipulations necessary to get this function to work. In essence, all I need is a single input parameter, Address. I have successfully manipulated the xaml side to display a single input parameter, know I just need to manipulate C# code to make this work. Any help would be awesome.

share|improve this question

Got it. I was using the wrong address field name. ESRI's address field for its geocoder is called "Address" While the name of my addres field is "Street".

        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);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.