Skip to content

Commit 455093c

Browse files
authored
Add Geography to Indoor functionality (#48)
* Add Geograpy to Indoor settings * Changes based on comments * Add options to comment/doc for Geography * Changed options.ts andindoor.ts to assign default to geography * Write default value for Geography in IndoorManagerOptionsJsonConverter Read geography value in IndoorManagerOptionsJsonConverter * Fix failing test
1 parent 5cf6101 commit 455093c

6 files changed

Lines changed: 30 additions & 7 deletions

File tree

samples/AzureMapsControl.Sample/Pages/Indoor/Index.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
var options = new AzureMapsControl.Components.Indoor.IndoorManagerOptions
2727
{
28+
Geography = Configuration["AzureMaps:Geography"],
2829
LevelControl = levelControl,
2930
StatesetId = statesetId,
3031
TilesetId = Configuration["Indoor:TilesetId"]

src/AzureMapsControl.Components/Indoor/IndoorManagerOptions.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ public struct IndoorManagerOptions
1919
/// </summary>
2020
public string StatesetId { get; set; }
2121

22+
/// <summary>
23+
/// The geography of the Creator resources.
24+
/// Possible values: "us" or "eu"
25+
/// </summary>
26+
public string Geography { get; set; }
27+
2228
/// <summary>
2329
/// The theme for indoor layer styles.
2430
/// </summary>
@@ -34,7 +40,7 @@ internal class IndoorManagerOptionsJsonConverter : JsonConverter<IndoorManagerOp
3440
{
3541
public override IndoorManagerOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
3642
{
37-
string statesetId = null, tilesetId = null;
43+
string statesetId = null, tilesetId = null, geography = null;
3844
IndoorLayerTheme theme = default;
3945

4046
if (reader.TokenType == JsonTokenType.None)
@@ -63,13 +69,19 @@ public override IndoorManagerOptions Read(ref Utf8JsonReader reader, Type typeTo
6369
reader.Read();
6470
tilesetId = reader.GetString();
6571
}
72+
else if (reader.GetString() == "geography")
73+
{
74+
reader.Read();
75+
geography = reader.GetString();
76+
}
6677
}
6778
}
6879

6980
return new IndoorManagerOptions {
7081
StatesetId = statesetId,
7182
Theme = theme,
72-
TilesetId = tilesetId
83+
TilesetId = tilesetId,
84+
Geography = geography
7385
};
7486
}
7587

@@ -89,6 +101,8 @@ public override void Write(Utf8JsonWriter writer, IndoorManagerOptions value, Js
89101
{
90102
writer.WriteString("theme", value.Theme.ToString());
91103
}
104+
105+
writer.WriteString("geography", value.Geography ?? "us");
92106
writer.WriteString("tilesetId", value.TilesetId);
93107
writer.WriteEndObject();
94108
}

src/AzureMapsControl.Components/typescript/indoor/indoor.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ export class Indoor {
1717
if (!options.theme) {
1818
options.theme = 'auto';
1919
}
20+
if (!options.geography) {
21+
options.geography = 'us';
22+
}
2023

2124
const map = Core.getMap();
2225
const indoorManager = new indoor.indoor.IndoorManager(map, {
2326
levelControl,
2427
statesetId: options.statesetId,
2528
theme: options.theme,
26-
tilesetId: options.tilesetId
29+
tilesetId: options.tilesetId,
30+
geography: options.geography
2731
});
2832

2933
if (events) {
@@ -66,7 +70,8 @@ export class Indoor {
6670
return {
6771
statesetId: options.statesetId,
6872
theme: options.theme,
69-
tilesetId: options.tilesetId
73+
tilesetId: options.tilesetId,
74+
geography: options.geography
7075
};
7176
}
7277

src/AzureMapsControl.Components/typescript/indoor/options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export interface IndoorManagerOptions {
77
statesetId: string;
88
theme: 'auto' | 'dark' | 'light';
99
tilesetId: string;
10+
geography: 'us' | 'eu';
1011
}

src/AzureMapsControl.Components/typings/Indoor/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ declare namespace atlas {
286286
export class IndoorManagerOptions {
287287
/**
288288
* The geography of the Creator resource.
289-
* @default "United States";
289+
* @default "us";
290290
*/
291-
public geography?: "United States";
291+
public geography?: "us" | "eu";
292292

293293
/**
294294
* A level picker to display as a control for the indoor manager.

tests/AzureMapsControl.Components.Tests/Indoor/IndoorManagerOptions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public void Should_Write()
2222
LevelControl = levelControl,
2323
StatesetId = "statesetId",
2424
Theme = IndoorLayerTheme.Auto,
25-
TilesetId = "tilesetId"
25+
TilesetId = "tilesetId",
26+
Geography = "us"
2627
};
2728

2829
var expectedJson = "{"
@@ -35,6 +36,7 @@ public void Should_Write()
3536
+ ",\"statesetId\":\"statesetId\""
3637
+ ",\"theme\":\"auto\""
3738
+ ",\"tilesetId\":\"tilesetId\""
39+
+ ",\"geography\":\"us\""
3840
+ "}";
3941

4042
TestAndAssertWrite(options, expectedJson);

0 commit comments

Comments
 (0)