Select to view content in your preferred language

WPF .NET Locator Searching Intersections

361
0
10-24-2019 12:39 PM
DerekCrocker
New Contributor

I am using StreetMap Premium (Mobile Map Package). The Locator/MMPK does support IntersectionLookup, but no matter how I search for the intersection it does not seem to locate it. I have tried [Street Name] & [Other Street Name] as well as [Street Name] / [Other Street Name] with no luck. (Main St & Queen St).

Code:

// Return gracefully if the textbox is empty or the geocoder isn't ready
if (String.IsNullOrWhiteSpace(enteredText) || geocoder == null) { return; }

SuggestParameters suggestParameters = new SuggestParameters();
suggestParameters.MaxResults = 15;

// Get suggestions based on the input text
IReadOnlyList<SuggestResult> suggestions = await geocoder.SuggestAsync(enteredText, suggestParameters);

// Stop gracefully if there are no suggestions
if (suggestions.Count < 1) { return; }

if (suggestions.Count > 1)
{
ListFoundAddresses(suggestions); //Display results to listbox
}
// Get the full address for the first suggestion
SuggestResult firstSuggestion = suggestions.First();
IReadOnlyList<GeocodeResult> addresses = await geocoder.GeocodeAsync(firstSuggestion.Label);

// Stop gracefully if the geocoder does not return a result
if (addresses.Count < 1) { return; }

// Place a marker on the map - 1. Create the overlay
GraphicsOverlay resultOverlay = new GraphicsOverlay();
// 2. Get the Graphic to display
MapPoint mp = addresses.First().DisplayLocation;
Graphic point = await GraphicForPoint(mp);
// 3. Add the Graphic to the GraphicsOverlay
//resultOverlay.Graphics.Add(point);
GraphicsOverlay_Address.Graphics.Add(point);
// 4. Add the GraphicsOverlay to the MapView
//MyMapView.GraphicsOverlays.Add(resultOverlay);

// Update the map extent to show the marker
await MyMapView.SetViewpointGeometryAsync(addresses.First().Extent);

0 Kudos
0 Replies