Skip to content

Commit

Permalink
Add Geography to Indoor functionality (#48)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
vnbaaij authored Jun 19, 2021
1 parent 5cf6101 commit 455093c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions samples/AzureMapsControl.Sample/Pages/Indoor/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

var options = new AzureMapsControl.Components.Indoor.IndoorManagerOptions
{
Geography = Configuration["AzureMaps:Geography"],
LevelControl = levelControl,
StatesetId = statesetId,
TilesetId = Configuration["Indoor:TilesetId"]
Expand Down
18 changes: 16 additions & 2 deletions src/AzureMapsControl.Components/Indoor/IndoorManagerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public struct IndoorManagerOptions
/// </summary>
public string StatesetId { get; set; }

/// <summary>
/// The geography of the Creator resources.
/// Possible values: "us" or "eu"
/// </summary>
public string Geography { get; set; }

/// <summary>
/// The theme for indoor layer styles.
/// </summary>
Expand All @@ -34,7 +40,7 @@ internal class IndoorManagerOptionsJsonConverter : JsonConverter<IndoorManagerOp
{
public override IndoorManagerOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
string statesetId = null, tilesetId = null;
string statesetId = null, tilesetId = null, geography = null;
IndoorLayerTheme theme = default;

if (reader.TokenType == JsonTokenType.None)
Expand Down Expand Up @@ -63,13 +69,19 @@ public override IndoorManagerOptions Read(ref Utf8JsonReader reader, Type typeTo
reader.Read();
tilesetId = reader.GetString();
}
else if (reader.GetString() == "geography")
{
reader.Read();
geography = reader.GetString();
}
}
}

return new IndoorManagerOptions {
StatesetId = statesetId,
Theme = theme,
TilesetId = tilesetId
TilesetId = tilesetId,
Geography = geography
};
}

Expand All @@ -89,6 +101,8 @@ public override void Write(Utf8JsonWriter writer, IndoorManagerOptions value, Js
{
writer.WriteString("theme", value.Theme.ToString());
}

writer.WriteString("geography", value.Geography ?? "us");
writer.WriteString("tilesetId", value.TilesetId);
writer.WriteEndObject();
}
Expand Down
9 changes: 7 additions & 2 deletions src/AzureMapsControl.Components/typescript/indoor/indoor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ export class Indoor {
if (!options.theme) {
options.theme = 'auto';
}
if (!options.geography) {
options.geography = 'us';
}

const map = Core.getMap();
const indoorManager = new indoor.indoor.IndoorManager(map, {
levelControl,
statesetId: options.statesetId,
theme: options.theme,
tilesetId: options.tilesetId
tilesetId: options.tilesetId,
geography: options.geography
});

if (events) {
Expand Down Expand Up @@ -66,7 +70,8 @@ export class Indoor {
return {
statesetId: options.statesetId,
theme: options.theme,
tilesetId: options.tilesetId
tilesetId: options.tilesetId,
geography: options.geography
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export interface IndoorManagerOptions {
statesetId: string;
theme: 'auto' | 'dark' | 'light';
tilesetId: string;
geography: 'us' | 'eu';
}
4 changes: 2 additions & 2 deletions src/AzureMapsControl.Components/typings/Indoor/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ declare namespace atlas {
export class IndoorManagerOptions {
/**
* The geography of the Creator resource.
* @default "United States";
* @default "us";
*/
public geography?: "United States";
public geography?: "us" | "eu";

/**
* A level picker to display as a control for the indoor manager.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public void Should_Write()
LevelControl = levelControl,
StatesetId = "statesetId",
Theme = IndoorLayerTheme.Auto,
TilesetId = "tilesetId"
TilesetId = "tilesetId",
Geography = "us"
};

var expectedJson = "{"
Expand All @@ -35,6 +36,7 @@ public void Should_Write()
+ ",\"statesetId\":\"statesetId\""
+ ",\"theme\":\"auto\""
+ ",\"tilesetId\":\"tilesetId\""
+ ",\"geography\":\"us\""
+ "}";

TestAndAssertWrite(options, expectedJson);
Expand Down

0 comments on commit 455093c

Please sign in to comment.