Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Automated] Sync v.next with main #1488

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/MAUI/Maui.Samples/Samples/Search/FindPlace/FindPlace.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ private async Task UpdateSearch(string enteredText, string locationText, bool re

// Create the geocode parameters.
GeocodeParameters parameters = new GeocodeParameters();

// Request that the "Address" attribute is included with results, to display in callouts.
parameters.ResultAttributeNames.Add("Address");

try
{
// Get the MapPoint for the current search location.
Expand All @@ -146,6 +150,9 @@ private async Task UpdateSearch(string enteredText, string locationText, bool re
if (searchLocation != null)
{
parameters.PreferredSearchLocation = searchLocation;

// Raise MinScore to a non-zero value, otherwise PreferredSearchLocation has no effect.
parameters.MinScore = 1;
}

// Update the search area if desired.
Expand Down Expand Up @@ -174,24 +181,18 @@ private async Task UpdateSearch(string enteredText, string locationText, bool re

// Create the GraphicsOverlay so that results can be drawn on the map.
GraphicsOverlay resultOverlay = new GraphicsOverlay();
var symbol = await GetPinSymbolAsync();


// Add each address to the map.
foreach (GeocodeResult location in locations)
{
// Get the Graphic to display.
Graphic point = await GraphicForPoint(location.DisplayLocation);
var point = new Graphic(location.DisplayLocation, symbol);

// Add the specific result data to the point.
point.Attributes["Match_Title"] = location.Label;

// Get the address for the point.
IReadOnlyList<GeocodeResult> addresses = await _geocoder.ReverseGeocodeAsync(location.DisplayLocation);

// Add the first suitable address if possible.
if (addresses.Any())
{
point.Attributes["Match_Address"] = addresses.First().Label;
}
point.Attributes["Match_Address"] = location.Attributes["Address"];

// Add the Graphic to the GraphicsOverlay.
resultOverlay.Graphics.Add(point);
Expand All @@ -212,7 +213,10 @@ private async Task UpdateSearch(string enteredText, string locationText, bool re
}
}

private async Task<Graphic> GraphicForPoint(MapPoint point)
/// <summary>
/// Creates and returns a "Pin" symbol used to mark search results on the MapView.
/// </summary>
private async Task<Esri.ArcGISRuntime.Symbology.Symbol> GetPinSymbolAsync()
{
// Get current assembly that contains the image.
Assembly currentAssembly = Assembly.GetExecutingAssembly();
Expand All @@ -230,7 +234,7 @@ private async Task<Graphic> GraphicForPoint(MapPoint point)
// is on the point rather than the image's true center.
pinSymbol.LeaderOffsetX = 30;
pinSymbol.OffsetY = 14;
return new Graphic(point, pinSymbol);
return pinSymbol;
}

private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Maui.GeoViewInputEventArgs e)
Expand Down
25 changes: 12 additions & 13 deletions src/WPF/WPF.Viewer/Samples/Search/FindPlace/FindPlace.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,19 @@ private async Task UpdateSearch(string enteredText, string locationText, bool re
// Create the geocode parameters.
GeocodeParameters parameters = new GeocodeParameters();

// Request that the "Address" attribute is included with results, to display in callouts.
parameters.ResultAttributeNames.Add("Address");

// Get the MapPoint for the current search location.
MapPoint searchLocation = await GetSearchMapPoint(locationText);

// Update the geocode parameters if the map point is not null.
if (searchLocation != null)
{
parameters.PreferredSearchLocation = searchLocation;

// Raise MinScore to a non-zero value, otherwise PreferredSearchLocation has no effect.
parameters.MinScore = 1;
}

// Update the search area if desired.
Expand All @@ -179,24 +185,17 @@ private async Task UpdateSearch(string enteredText, string locationText, bool re

// Create the GraphicsOverlay so that results can be drawn on the map.
GraphicsOverlay resultOverlay = new GraphicsOverlay();
var symbol = await GetPinSymbolAsync();

// Add each address to the map.
foreach (GeocodeResult location in locations)
{
// Get the Graphic to display.
Graphic point = await GraphicForPoint(location.DisplayLocation);
var point = new Graphic(location.DisplayLocation, symbol);

// Add the specific result data to the point.
point.Attributes["Match_Title"] = location.Label;

// Get the address for the point.
IReadOnlyList<GeocodeResult> addresses = await _geocoder.ReverseGeocodeAsync(location.DisplayLocation);

// Add the first suitable address if possible.
if (addresses.Any())
{
point.Attributes["Match_Address"] = addresses[0].Label;
}
point.Attributes["Match_Address"] = location.Attributes["Address"];

// Add the Graphic to the GraphicsOverlay.
resultOverlay.Graphics.Add(point);
Expand All @@ -218,9 +217,9 @@ private async Task UpdateSearch(string enteredText, string locationText, bool re
}

/// <summary>
/// Creates and returns a Graphic associated with the given MapPoint.
/// Creates and returns a "Pin" symbol used to mark search results on the MapView.
/// </summary>
private async Task<Graphic> GraphicForPoint(MapPoint point)
private async Task<Esri.ArcGISRuntime.Symbology.Symbol> GetPinSymbolAsync()
{
// Hold a reference to the picture marker symbol.
PictureMarkerSymbol pinSymbol;
Expand All @@ -245,7 +244,7 @@ private async Task<Graphic> GraphicForPoint(MapPoint point)
pinSymbol.OffsetY = 14;
}

return new Graphic(point, pinSymbol);
return pinSymbol;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using ArcGIS.Samples.Shared.Managers;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Location;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.Tasks.Geocoding;
Expand Down Expand Up @@ -144,6 +145,9 @@ private async Task UpdateSearch(string enteredText, string locationText, bool re
// Create the geocode parameters
GeocodeParameters parameters = new GeocodeParameters();

// Request that the "Address" attribute is included with results, to display in callouts.
parameters.ResultAttributeNames.Add("Address");

try
{
// Get the MapPoint for the current search location
Expand All @@ -153,6 +157,9 @@ private async Task UpdateSearch(string enteredText, string locationText, bool re
if (searchLocation != null)
{
parameters.PreferredSearchLocation = searchLocation;

// Raise MinScore to a non-zero value, otherwise PreferredSearchLocation has no effect.
parameters.MinScore = 1;
}

// Update the search area if desired
Expand Down Expand Up @@ -181,24 +188,17 @@ private async Task UpdateSearch(string enteredText, string locationText, bool re

// Create the GraphicsOverlay so that results can be drawn on the map
GraphicsOverlay resultOverlay = new GraphicsOverlay();
var symbol = await GetPinSymbolAsync();

// Add each address to the map
foreach (GeocodeResult location in locations)
{
// Get the Graphic to display
Graphic point = await GraphicForPoint(location.DisplayLocation);
var point = new Graphic(location.DisplayLocation, symbol);

// Add the specific result data to the point
point.Attributes["Match_Title"] = location.Label;

// Get the address for the point
IReadOnlyList<GeocodeResult> addresses = await _geocoder.ReverseGeocodeAsync(location.DisplayLocation);

// Add the first suitable address if possible
if (addresses.Any())
{
point.Attributes["Match_Address"] = addresses[0].Label;
}
point.Attributes["Match_Address"] = location.Attributes["Address"];

// Add the Graphic to the GraphicsOverlay
resultOverlay.Graphics.Add(point);
Expand All @@ -220,9 +220,9 @@ private async Task UpdateSearch(string enteredText, string locationText, bool re
}

/// <summary>
/// Creates and returns a Graphic associated with the given MapPoint
/// Creates and returns a "Pin" symbol used to mark search results on the MapView
/// </summary>
private async Task<Graphic> GraphicForPoint(MapPoint point)
private async Task<Esri.ArcGISRuntime.Symbology.Symbol> GetPinSymbolAsync()
{
// Get current assembly that contains the image
Assembly currentAssembly = GetType().GetTypeInfo().Assembly;
Expand All @@ -240,7 +240,7 @@ private async Task<Graphic> GraphicForPoint(MapPoint point)
// is on the point rather than the image's true center
pinSymbol.LeaderOffsetX = 30;
pinSymbol.OffsetY = 14;
return new Graphic(point, pinSymbol);
return pinSymbol;
}

/// <summary>
Expand Down
Loading