Skip to content

Commit

Permalink
Merge branch 'features/azure-maps-indoor' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudleclerc committed May 31, 2021
2 parents b1288e9 + 502ded6 commit f431639
Show file tree
Hide file tree
Showing 63 changed files with 5,304 additions and 43 deletions.
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This library allows you to use `Azure Maps` inside your razor application.

## Install the Nuget Package

This library is available on Nuget as `AzureMapsControl.Components`.
This library is available on [Nuget](https://www.nuget.org/packages/AzureMapsControl.Components/) as `AzureMapsControl.Components`.

## Setup

Expand All @@ -29,16 +29,6 @@ Or use the minimized version :
<script src="_content/AzureMapsControl.Components/azure-maps-control.min.js"></script>
```

If you plan to use the drawing toolbar, you also need to include the following css and scripts :

```
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/drawing/0.1/atlas-drawing.min.css" type="text/css" />
```

```
<script src="https://atlas.microsoft.com/sdk/javascript/drawing/0.1/atlas-drawing.min.js"></script>
```

### Register the Components

You will need to pass the authentication information of your `AzureMaps` instance to the library. `SubscriptionKey`, `Aad` and `Anonymous` authentication are supported. You will need to call the `AddAzureMapsControl` method on your services.
Expand Down Expand Up @@ -151,6 +141,7 @@ It also needs to fetch the token to send to the requests of the atlas library. F
- [Traffic](docs/traffic)
- [Expressions](docs/expressions)
- [Animations](docs/animations)
- [Indoor Module](docs/indoor)

## Want to contribute ?

Expand Down
Binary file added docs/assets/indoor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions docs/drawingtoolbar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

![Drawing Toolbar](../assets/drawingtoolbar.png)

A Drawing toolbar can be added to the map by providing the `DrawingToolbarOptions` parameter on the `AzureMap` component.
A Drawing toolbar can be added to the map by providing the `DrawingToolbarOptions` parameter on the `AzureMap` component. You will need to include the following css and script into your application :

```
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/drawing/0.1/atlas-drawing.min.css" type="text/css" />
```

```
<script src="https://atlas.microsoft.com/sdk/javascript/drawing/0.1/atlas-drawing.min.js"></script>
```

```
@page "/DrawingToolbar"
Expand Down Expand Up @@ -62,7 +70,7 @@ It can also be added once the map is ready.
You can specify the events to enable or disable on the `DrawingToolbarOptions` of the toolbar. By default, all events are deactivated. The following events are available :

| Event | Description |
| -- | -- | -- |
| -- | -- |
| `DrawingChanged` | Fired when any coordinate in a shape has been added or changed. |
| `DrawingChanging` | Fired when any preview coordinate for a shape is being displayed. For example, this event will fire multiple times as a coordinate is dragged. |
| `DrawingComplete` | Fired when a shape has finished being drawn or taken out of edit mode. |
Expand Down
89 changes: 89 additions & 0 deletions docs/indoor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
## Indoor Module

![Indoor Module](../assets/indoor.png)

You can use the `Azure Maps Indoor module` with this library. The `Azure Maps Indoor module` allows you to render indoor maps created in Azure Maps Creator services (Preview). To use this module, you will need to reference the following css and script in your application :


```
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/indoor/0.1/atlas-indoor.min.css" type="text/css" />
```

```
<script src="https://atlas.microsoft.com/sdk/javascript/indoor/0.1/atlas-indoor.js"></script>
```

### IIndoorService

The entry point is the `IIndoorService` interface. This interface can be injected into your services and Razor Pages and allows you to create an `IndoorManager` via the `CreateIndoorManagerAsync` method.

### IndoorManager

An IndoorManager handles loading the indoor maps styles. Having an instance of `IndoorManager allows you for example to modify the styles of the indoor maps, set the facility and level you want to display or react to events. Following events are supported :

| Event | Description |
| -- | -- |
| `OnFacilityChanged` | Fired when when the facility changes. |
| `OnLevelChanged` | Fired when when the level changes. |

### Sample

The following sample code is the adaptation of this [sample](https://docs.microsoft.com/en-us/azure/azure-maps/how-to-use-indoor-module#example-use-the-indoor-maps-module).

```
@page "/Indoor"
@using AzureMapsControl.Components.Map
@using Microsoft.Extensions.Configuration
@inject AzureMapsControl.Components.Indoor.IIndoorService IndoorService
@inject IConfiguration Configuration
<AzureMap Id="map"
CameraOptions="new CameraOptions { Center= new AzureMapsControl.Components.Atlas.Position(-122.13214, 47.63647), Zoom = 19 }"
StyleOptions="new StyleOptions { Style = MapStyle.Blank }"
EventActivationFlags="AzureMapsControl.Components.Map.MapEventActivationFlags.None().Enable(AzureMapsControl.Components.Map.MapEventType.Ready, AzureMapsControl.Components.Map.MapEventType.Click)"
OnReady="OnMapReadyAsync" />
@code {
public async Task OnMapReadyAsync(MapEventArgs eventArgs)
{
var levelControl = new AzureMapsControl.Components.Indoor.LevelControl(new AzureMapsControl.Components.Indoor.LevelControlOptions
{
Position = AzureMapsControl.Components.Controls.ControlPosition.TopRight
});
var statesetId = Configuration["Indoor:StatesetId"];
var options = new AzureMapsControl.Components.Indoor.IndoorManagerOptions
{
LevelControl = levelControl,
StatesetId = statesetId,
TilesetId = Configuration["Indoor:TilesetId"]
};
var indoorManager = await IndoorService.CreateIndoorManagerAsync(options, Components.Indoor.IndoorManagerEventActivationFlags.All());
indoorManager.OnFacilityChanged += eventArgs =>
{
Console.WriteLine("OnFacilityChanged");
Console.WriteLine($"Switched facility from {eventArgs.PrevFacilityId} to {eventArgs.FacilityId}");
Console.WriteLine($"Switched level from {eventArgs.PrevLevelNumber} to {eventArgs.LevelNumber}");
};
indoorManager.OnLevelChanged += eventArgs =>
{
Console.WriteLine("OnLevelChanged");
Console.WriteLine($"Switched facility from {eventArgs.PrevFacilityId} to {eventArgs.FacilityId}");
Console.WriteLine($"Switched level from {eventArgs.PrevLevelNumber} to {eventArgs.LevelNumber}");
};
if (!string.IsNullOrWhiteSpace(statesetId))
{
await indoorManager.SetDynamicStylingAsync(true);
}
}
}
```
55 changes: 55 additions & 0 deletions samples/AzureMapsControl.Sample/Pages/Indoor/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@page "/Indoor"

@using AzureMapsControl.Components.Map
@using Microsoft.Extensions.Configuration

@inject AzureMapsControl.Components.Indoor.IIndoorService IndoorService
@inject IConfiguration Configuration

<AzureMap Id="map"
CameraOptions="new CameraOptions { Center= new AzureMapsControl.Components.Atlas.Position(-122.13214, 47.63647), Zoom = 19 }"
StyleOptions="new StyleOptions { Style = MapStyle.Blank }"
EventActivationFlags="AzureMapsControl.Components.Map.MapEventActivationFlags.None().Enable(AzureMapsControl.Components.Map.MapEventType.Ready, AzureMapsControl.Components.Map.MapEventType.Click)"
OnReady="OnMapReadyAsync" />

@code {

public async Task OnMapReadyAsync(MapEventArgs eventArgs)
{
var levelControl = new AzureMapsControl.Components.Indoor.LevelControl(new AzureMapsControl.Components.Indoor.LevelControlOptions
{
Position = AzureMapsControl.Components.Controls.ControlPosition.TopRight
});

var statesetId = Configuration["Indoor:StatesetId"];

var options = new AzureMapsControl.Components.Indoor.IndoorManagerOptions
{
LevelControl = levelControl,
StatesetId = statesetId,
TilesetId = Configuration["Indoor:TilesetId"]
};

var indoorManager = await IndoorService.CreateIndoorManagerAsync(options, Components.Indoor.IndoorManagerEventActivationFlags.All());

indoorManager.OnFacilityChanged += eventArgs =>
{
Console.WriteLine("OnFacilityChanged");
Console.WriteLine($"Switched facility from {eventArgs.PrevFacilityId} to {eventArgs.FacilityId}");
Console.WriteLine($"Switched level from {eventArgs.PrevLevelNumber} to {eventArgs.LevelNumber}");
};

indoorManager.OnLevelChanged += eventArgs =>
{
Console.WriteLine("OnLevelChanged");
Console.WriteLine($"Switched facility from {eventArgs.PrevFacilityId} to {eventArgs.FacilityId}");
Console.WriteLine($"Switched level from {eventArgs.PrevLevelNumber} to {eventArgs.LevelNumber}");
};

if (!string.IsNullOrWhiteSpace(statesetId))
{
await indoorManager.SetDynamicStylingAsync(true);
}
}

}
2 changes: 2 additions & 0 deletions samples/AzureMapsControl.Sample/Pages/_Host.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<base href="~/" />
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.css" type="text/css" />
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/drawing/0.1/atlas-drawing.min.css" type="text/css" />
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/indoor/0.1/atlas-indoor.min.css" type="text/css" />
<style>
body {
margin: 0;
Expand All @@ -33,6 +34,7 @@
</app>
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.js"></script>
<script src="https://atlas.microsoft.com/sdk/javascript/drawing/0.1/atlas-drawing.min.js"></script>
<script src="https://atlas.microsoft.com/sdk/javascript/indoor/0.1/atlas-indoor.js"></script>
<script src="~/azure-maps-scale-bar-control.min.js"></script>
<script src="~/azure-maps-overview-map.min.js"></script>
<script src="~/azure-maps-animations.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion samples/AzureMapsControl.Sample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void ConfigureServices(IServiceCollection services)
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
if (env.IsDevelopment() || env.IsEnvironment("GenTwo"))
{
app.UseDeveloperExceptionPage();
}
Expand Down
2 changes: 1 addition & 1 deletion src/AzureMapsControl.Components/Atlas/Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public ExpressionOrStringArray(JsonDocument json): base(json) { }

internal abstract class ExpressionBaseJsonConverter<T> : JsonConverter<T> where T : Expression
{
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotSupportedException();

public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) => WriteExpression(writer, value, options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public sealed class DateTimeFormatOptions

internal class DateTimeFormatOptionsJsonConverter : JsonConverter<DateTimeFormatOptions>
{
public override DateTimeFormatOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
public override DateTimeFormatOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotSupportedException();
public override void Write(Utf8JsonWriter writer, DateTimeFormatOptions value, JsonSerializerOptions options)
{
if (value is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public struct HyperLinkFormatOptionsTarget

internal class HyperLinkFormatOptionsTargetJsonConverter : JsonConverter<HyperLinkFormatOptionsTarget>
{
public override HyperLinkFormatOptionsTarget Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
public override HyperLinkFormatOptionsTarget Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotSupportedException();
public override void Write(Utf8JsonWriter writer, HyperLinkFormatOptionsTarget value, JsonSerializerOptions options) => writer.WriteStringValue(value.ToString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public sealed class NumberFormatOptions

internal class NumberFormatOptionsJsonConverter : JsonConverter<NumberFormatOptions>
{
public override NumberFormatOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
public override NumberFormatOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotSupportedException();
public override void Write(Utf8JsonWriter writer, NumberFormatOptions value, JsonSerializerOptions options)
{
if (value is not null)
Expand Down
2 changes: 1 addition & 1 deletion src/AzureMapsControl.Components/Atlas/Geometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public override Geometry Read(ref Utf8JsonReader reader, Type typeToConvert, Jso
};
}

public override void Write(Utf8JsonWriter writer, Geometry value, JsonSerializerOptions options) => throw new NotImplementedException();
public override void Write(Utf8JsonWriter writer, Geometry value, JsonSerializerOptions options) => throw new NotSupportedException();

internal static dynamic ReadCoordinates(ref Utf8JsonReader reader)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,4 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
</ItemGroup>


<ItemGroup>
<Folder Include="typings\GeolocationControl\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal string AuthType

internal sealed class AzureMapsConfigurationJsonConverter : JsonConverter<AzureMapsConfiguration>
{
public override AzureMapsConfiguration Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
public override AzureMapsConfiguration Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotSupportedException();
public override void Write(Utf8JsonWriter writer, AzureMapsConfiguration value, JsonSerializerOptions options)
{
writer.WriteStartObject();
Expand Down
14 changes: 14 additions & 0 deletions src/AzureMapsControl.Components/Constants/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal static class Namespaces
internal const string OverviewMapControl = "OverviewMapControl";
internal const string GeolocationControl = "GeolocationControl";
internal const string FullScreenControl = "FullscreenControl";
internal const string Indoor = "Indoor";
}

internal static class Methods
Expand Down Expand Up @@ -132,6 +133,19 @@ internal static class FullScreenControl
internal const string IsFullScreen = "isFullscreen";
internal const string AddEvents = "addEvents";
}

internal static class Indoor
{
internal const string CreateIndoorManager = "createIndoorManager";
internal const string Initialize = "initialize";
internal const string Dispose = "dispose";
internal const string GetCurrentFacility = "getCurrentFacility";
internal const string GetOptions = "getOptions";
internal const string GetStyleDefinition = "getStyleDefinition";
internal const string SetDynamicStyling = "setDynamicStyling";
internal const string SetFacility = "setFacility";
internal const string SetOptions = "setOptions";
}
}
}
}
2 changes: 1 addition & 1 deletion src/AzureMapsControl.Components/Controls/CompassControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public CompassControl(CompassControlOptions options = null, ControlPosition posi

internal class CompassControlJsonConverter : JsonConverter<CompassControl>
{
public override CompassControl Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
public override CompassControl Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotSupportedException();
public override void Write(Utf8JsonWriter writer, CompassControl value, JsonSerializerOptions options) => Write(writer, value);

internal static void Write(Utf8JsonWriter writer, CompassControl value)
Expand Down
2 changes: 1 addition & 1 deletion src/AzureMapsControl.Components/Controls/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public abstract class Control<T> : Control

internal class ControlJsonConverter : JsonConverter<Control>
{
public override Control Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
public override Control Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotSupportedException();
public override void Write(Utf8JsonWriter writer, Control value, JsonSerializerOptions options)
{
switch (value.Type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void EnsureJsRuntimeExists()

internal class FullScreenControlJsonConverter : JsonConverter<FullScreenControl>
{
public override FullScreenControl Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
public override FullScreenControl Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotSupportedException();
public override void Write(Utf8JsonWriter writer, FullScreenControl value, JsonSerializerOptions options) => Write(writer, value);

internal static void Write(Utf8JsonWriter writer, FullScreenControl value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private void EnsureJsRuntimeExists()

internal class GeolocationControlJsonConverter : JsonConverter<GeolocationControl>
{
public override GeolocationControl Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
public override GeolocationControl Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotSupportedException();
public override void Write(Utf8JsonWriter writer, GeolocationControl value, JsonSerializerOptions options) => Write(writer, value);

public static void Write(Utf8JsonWriter writer, GeolocationControl value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async ValueTask SetOptionsAsync(Action<OverviewMapControlOptions> update)

internal class OverviewMapControlJsonConverter : JsonConverter<OverviewMapControl>
{
public override OverviewMapControl Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
public override OverviewMapControl Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotSupportedException();
public override void Write(Utf8JsonWriter writer, OverviewMapControl value, JsonSerializerOptions options) => Write(writer, value);

internal static void Write(Utf8JsonWriter writer, OverviewMapControl value)
Expand Down
2 changes: 1 addition & 1 deletion src/AzureMapsControl.Components/Controls/PitchControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public PitchControl(PitchControlOptions options = null, ControlPosition position

internal class PitchControlJsonConverter : JsonConverter<PitchControl>
{
public override PitchControl Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException();
public override PitchControl Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotSupportedException();
public override void Write(Utf8JsonWriter writer, PitchControl value, JsonSerializerOptions options) => Write(writer, value);

internal static void Write(Utf8JsonWriter writer, PitchControl value)
Expand Down
Loading

0 comments on commit f431639

Please sign in to comment.