Skip to content

Commit 1dc721a

Browse files
Change ILDS constructor (#1467)
1 parent 054cf7c commit 1dc721a

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

src/MAUI/Maui.Samples/Samples/Location/IndoorPositioning/IndoorPositioning.xaml.cs

+3-29
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ public partial class IndoorPositioning : ContentPage, IDisposable
3838

3939
private const string ItemId = "YOUR_ITEM_ID_HERE";
4040

41-
private const string PositioningTableName = "IPS_Positioning";
42-
private const string PathwaysLayerName = "Pathways";
43-
4441
private string[] _layerNames = new string[] { "Details", "Units", "Levels" };
4542

4643
#endregion BuildingData
@@ -80,31 +77,8 @@ private async Task Initialize()
8077

8178
PositioningLabel.Text = "Creating indoors location data source";
8279

83-
// Get the positioning table from the map.
84-
await Task.WhenAll(MyMapView.Map.Tables.Select(table => table.LoadAsync()));
85-
FeatureTable positioningTable = MyMapView.Map.Tables.Single(table => table.TableName.Equals(PositioningTableName));
86-
87-
// Get a table of all of the indoor pathways.
88-
FeatureLayer pathwaysFeatureLayer = MyMapView.Map.OperationalLayers.OfType<FeatureLayer>().Single(l => l.Name.Equals(PathwaysLayerName, StringComparison.InvariantCultureIgnoreCase));
89-
ArcGISFeatureTable pathwaysTable = pathwaysFeatureLayer.FeatureTable as ArcGISFeatureTable;
90-
91-
// Get the global ID for positioning. The ID identifies a specific row in the feature table that should be used for setting up IPS. We use this ID to construct the data source.
92-
Field dateCreatedFieldName = positioningTable.Fields.Single(f => f.Name.Equals("DateCreated", StringComparison.InvariantCultureIgnoreCase) || f.Name.Equals("DATE_CREATED", StringComparison.InvariantCultureIgnoreCase));
93-
94-
// Create a query for the latest created feature. This is needed for correctly constructing the IPS used in this sample. There is a constructor without an ID parameter that will attempt to automatically find the latest row.
95-
QueryParameters queryParameters = new QueryParameters
96-
{
97-
MaxFeatures = 1,
98-
// "1=1" will give all the features from the table.
99-
WhereClause = "1=1",
100-
};
101-
queryParameters.OrderByFields.Add(new OrderBy(dateCreatedFieldName.Name, SortOrder.Descending));
102-
103-
FeatureQueryResult queryResult = await positioningTable.QueryFeaturesAsync(queryParameters);
104-
Guid globalID = (Guid)queryResult.Single().Attributes["GlobalID"];
105-
106-
// Create the indoor location data source using the tables and Guid.
107-
_indoorsLocationDataSource = new IndoorsLocationDataSource(positioningTable, pathwaysTable, globalID);
80+
// Create the indoor location data source using the IndoorPositioningDefinition from the map.
81+
_indoorsLocationDataSource = new IndoorsLocationDataSource(MyMapView.Map.IndoorPositioningDefinition);
10882

10983
PositioningLabel.Text = "Starting IPS";
11084

@@ -159,7 +133,7 @@ private void LocationDisplay_LocationChanged(object sender, Location loc)
159133
labelText += $"Horizontal accuracy: {string.Format("{0:0.##}", loc.HorizontalAccuracy)}m";
160134

161135
// Update UI on the main thread.
162-
Dispatcher.Dispatch(() =>
136+
Dispatcher.DispatchAsync(() =>
163137
{
164138
PositioningLabel.Text = labelText;
165139
});

src/MAUI/Maui.Samples/Samples/Location/IndoorPositioning/readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ When there is no IPS beacons nearby, or other errors occur while initializing th
1717
## How it works
1818

1919
1. Load an IPS-aware map. This can be a web map hosted as a portal item in ArcGIS Online, an Enterprise Portal, or a mobile map package (.mmpk) created with ArcGIS Pro.
20-
2. Create and load an `IndoorsLocationDataSource` with the positioning feature table (stored with the map), then create an `IndoorsLocationDataSource` from it.
20+
2. Create and load an `IndoorsLocationDataSource` (stored with the map), then create an `IndoorsLocationDataSource` from it.
2121
3. Handle location change events to respond to floor changes or read other metadata for locations.
2222
4. Assign the `IndoorsLocationDataSource` to the map view's location display.
2323
5. Enable and disable the map view's location display using `StartAsync()` and `StopAsync()`. Device location will appear on the display as a blue dot and update as the user moves throughout the space.

0 commit comments

Comments
 (0)