Select to view content in your preferred language

Locator Task

2252
5
Jump to solution
06-01-2014 07:00 AM
Labels (1)
eranz
by
Emerging Contributor
Hi,

Is there a way to locate address location by only partially search text?
I have tried the sample code (changed address Parameters):

if the search text is for example "2011 MISSION ST" i get no results...
how can i do this?

public LocalGeocode()         {             InitializeComponent();              FindText.Text = "1455 MARKET ST, SAN FRANCISCO, CA 94103";             FindText.Items.Add("2011 MISSION ST, SAN FRANCISCO  CA  94110");             FindText.Items.Add("820 BRYANT ST, SAN FRANCISCO  CA  94103");             FindText.SelectedIndex = 0;             _locationGraphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;              LocalGeocodeService.GetServiceAsync("..\\Data\\Locators\\SanFrancisco\\SanFranciscoLocator.gcpk", "SanFranciscoLocator", (gs) =>             {                 if (gs.Error != null)                 {                     MessageBox.Show(gs.Error.Message);                 }                 if (gs.Status == LocalServiceStatus.Running)                 {                     _localGeocodeService = gs;                     ExecuteButton.IsEnabled = true;                     DataContext = this;                     IsBusy = false;                 }             });         }          private void ExecuteButton_Click(object sender, RoutedEventArgs e)         {             IsBusy = true;             var searchText = FindText.Text;             Locator locatorTask = new Locator(_localGeocodeService.UrlGeocodeService);             locatorTask.AddressToLocationsCompleted += (object sender1, AddressToLocationsEventArgs args) =>             {                 if (args.Results.Count > 0)                 {                     AddressCandidate bestCandidate = args.Results[0];                     foreach (AddressCandidate candidate in args.Results)                         bestCandidate = (candidate.Score > bestCandidate.Score) ? candidate : bestCandidate;                      MapPoint geographicPoint = new MapPoint(bestCandidate.Location.X, bestCandidate.Location.Y, new SpatialReference(4326));                      Graphic graphic = new Graphic()                     {                         Geometry = geographicPoint,                         Symbol = LayoutRoot.Resources["StrobeMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol                     };                     _locationGraphicsLayer.Graphics.Clear();                     _locationGraphicsLayer.Graphics.Add(graphic);                     IsBusy = false;                 }                 else                 {                     MessageBox.Show("No results found");                     IsBusy = false;                 }             };              locatorTask.Failed += (s2, e2) =>             {                 MessageBox.Show("Geocode failed with error: " + e2.Error.Message);             };              AddressToLocationsParameters addressParameters = new AddressToLocationsParameters();             Dictionary<string, string> address = addressParameters.Address;                             //address.Add("Single Line Input", searchText); instead of this line i have tried searching             foreach (var addressField in _localGeocodeService.AddressesFields)            {                   address.Add(addressField.Name, searchText);            }                locatorTask.AddressToLocationsAsync(addressParameters);         }           }
0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor
Hi,

Yes, you could try adjusting the locator properties in ArcMap and test the geocoding there before repackaging.

Cheers

Mike

View solution in original post

0 Kudos
5 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

I would recommend using the Single-line address approach - http://resources.arcgis.com/en/help/main/10.2/index.html#//002500000022000000. Otherwise you will need to create a UI with specific fields for the individual elements of the address text and match those with the address fields exposed by the locator.

Cheers

Mike
0 Kudos
eranz
by
Emerging Contributor
Hi,

I would recommend using the Single-line address approach - http://resources.arcgis.com/en/help/main/10.2/index.html#//002500000022000000. Otherwise you will need to create a UI with specific fields for the individual elements of the address text and match those with the address fields exposed by the locator.

Cheers

Mike


Maybe i am missing a basic knowledge about locators...
This approach was my first test to search address with part of the text given in the local geocoding sample.
But it does not work... (didn't get any results - a dialog pops with no results message)
instead of ("2011 MISSION ST, SAN FRANCISCO  CA  94110", tried "2011 MISSION")
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

ArcGIS Locators either search specific fields or the single line address field. If you try specifying just a partial address in each field I suspect the matches are likely to be too vague and therefore no results returned (i.e. they do not match minimum required match score).

You should use either:
#. The single-line address field e.g http://resources.arcgis.com/en/help/runtime-wpf/samples/index.html#/Geocode/02q2000000nw000000/
OR
#. Multiple address fields e.g. http://resources.arcgis.com/en/help/runtime-wpf/samples/index.html#/Geocode_Online/02q2000000mq00000...

Cheers

Mike
0 Kudos
eranz
by
Emerging Contributor
Hi,

ArcGIS Locators either search specific fields or the single line address field. If you try specifying just a partial address in each field I suspect the matches are likely to be too vague and therefore no results returned (i.e. they do not match minimum required match score).

You should use either:
#. The single-line address field e.g http://resources.arcgis.com/en/help/runtime-wpf/samples/index.html#/Geocode/02q2000000nw000000/
OR
#. Multiple address fields e.g. http://resources.arcgis.com/en/help/runtime-wpf/samples/index.html#/Geocode_Online/02q2000000mq00000...

Cheers

Mike


Hi Mike,

Maybe i wasn't clear but my attempt was on ESRI sample "single-line address" (version 10.1) and tried to enter a partial address string
"2011 MISSION ST" - (No results)
"2011 MISSION ST, SAN FRANCISCO" - (No results)
"2011 MISSION ST, SAN FRANCISCO  CA" - (No results)
"2011 MISSION ST, SAN FRANCISCO  CA  94110" (only full text return results - why???)

Are you saying that those searches, all of them are  too vague? can i tell the locator to return even results with low score (change the minimum required match score)
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

Yes, you could try adjusting the locator properties in ArcMap and test the geocoding there before repackaging.

Cheers

Mike
0 Kudos