AzureMapsControl.Components 1.11.0

.NET 5.0
There is a newer prerelease version of this package available.
See the version list below for details.
Install-Package AzureMapsControl.Components -Version 1.11.0
dotnet add package AzureMapsControl.Components --version 1.11.0
<PackageReference Include="AzureMapsControl.Components" Version="1.11.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AzureMapsControl.Components --version 1.11.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AzureMapsControl.Components, 1.11.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install AzureMapsControl.Components as a Cake Addin
#addin nuget:?package=AzureMapsControl.Components&version=1.11.0

// Install AzureMapsControl.Components as a Cake Tool
#tool nuget:?package=AzureMapsControl.Components&version=1.11.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Nuget Nuget (with prereleases) Build Unit Test release codecov Slack

This library allows you to use Azure Maps inside your razor application.

Custom Azure Map

Install the Nuget Package

This library is available on Nuget as AzureMapsControl.Components.

Setup

Add the css and scripts

You will need to add the atlas script and css files as well as the script generated by the library on your application.

<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.css" type="text/css" />
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.js"></script>
<script src="_content/AzureMapsControl.Components/azure-maps-control.js"></script>

Or use the minimized version :

<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.js"></script>
<script src="_content/AzureMapsControl.Components/azure-maps-control.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.

You can authenticate using a subscription key :

    // This method gets called by the runtime. Use this method to add services to the container.
    // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddRazorPages();
        services.AddServerSideBlazor();
        
        services.AddAzureMapsControl(configuration => configuration.SubscriptionKey = "Your Subscription Key");
    }

Or using Azure Active Directory:

public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddServerSideBlazor(options => options.DetailedErrors = true);

            services.AddAzureMapsControl(configuration => {
                configuration.AadAppId = "Your Aad App Id";
                configuration.AadTenant = "Your Aad Tenant";
                configuration.ClientId = "Your Client Id";
            });
        }

The Anonymous authentication requires only a ClientId:

public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddServerSideBlazor(options => options.DetailedErrors = true);

            services.AddAzureMapsControl(configuration => configuration.ClientId = Configuration["AzureMaps:ClientId"])
        }

It also needs to fetch the token to send to the requests of the atlas library. For that, you have to override the azureMapsControl.Extensions.getTokenCallback method on your application after referencing azure-maps-control.min.js and resolve the token in it. For example :

@page "/"
@namespace AzureMapsControl.Sample.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
    Layout = null;
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>AzureMapsControl.Sample</title>
    <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" />
    <style>
        body {
            margin: 0;
        }

        #map {
            position: absolute;
            width: 100%;
            min-width: 290px;
            height: 100%;
        }
    </style>
</head>
<body>
    <app>
        <component type="typeof(App)" render-mode="ServerPrerendered" />
    </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="_content/AzureMapsControl.Components/azure-maps-control.min.js"></script>
    <script src="_framework/blazor.server.js"></script>
    <script type="text/javascript">
        azureMapsControl.Extensions.getTokenCallback = (resolve, reject, map) => {
            const url = "url_of_my_token_endpoint";
            fetch(url).then(function (response) {
                return response.text();
            }).then(function (token) {
                resolve(token);
            });        
        };
    </script>
</body>
</html>

How to use

Want to contribute ?

Contributions are welcome! One of the best way to start is to take a look at the list of issues where help is wanted.

If you need a new feature which is not listed on the issues, feel free to open a new one. Take also a look at the Contributing guidelines.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.12.0-alpha0004 71 2/2/2022
1.12.0-alpha0003 51 2/2/2022
1.11.0 2,989 11/12/2021
1.11.0-alpha0015 96 11/12/2021
1.10.0 168 11/8/2021
1.10.0-net60-alpha0001 92 10/19/2021
1.10.0-alpha0010 102 11/8/2021
1.9.0 1,091 8/4/2021
1.9.0-alpha0006 191 8/4/2021
1.8.3 824 7/14/2021
1.8.3-beta0001 171 7/14/2021
1.8.2 236 7/13/2021
1.8.2-beta0001 184 7/13/2021
1.8.1 354 6/25/2021
1.8.1-beta0001 219 6/25/2021
1.8.0 225 6/19/2021
1.8.0-html-marker-laye0001 187 6/8/2021
1.8.0-alpha0003 189 6/19/2021
1.7.1 334 6/8/2021
1.7.1-beta0001 182 6/3/2021
1.7.0 312 5/31/2021
1.7.0-alpha0014 198 5/31/2021
1.7.0-alpha0004 168 5/18/2021
1.7.0-alpha0001 172 5/13/2021
1.6.1 288 5/18/2021
1.6.1-beta0001 173 5/18/2021
1.6.0 261 5/7/2021
1.6.0-alpha0050 200 5/7/2021
1.6.0-alpha0031 218 5/7/2021
1.6.0-alpha0015 188 5/7/2021
1.5.2 219 5/6/2021
1.5.2-beta0001 202 5/6/2021
1.5.1 447 4/30/2021
1.5.1-beta0001 141 4/30/2021
1.5.0 222 4/26/2021
1.5.0-alpha0016 160 4/23/2021
1.4.0 198 4/23/2021
1.4.0-alpha0005 179 4/20/2021
1.3.0 261 4/19/2021
1.3.0-beta0003 200 4/17/2021
1.3.0-beta0002 183 4/17/2021
1.3.0-beta0001 197 4/17/2021
1.3.0-alpha0001 179 4/16/2021
1.2.0 185 4/15/2021
1.2.0-alpha0004 155 4/15/2021
1.1.0 230 4/13/2021
1.1.0-alpha0015 141 4/13/2021
1.0.0 245 4/9/2021
1.0.0-beta0008 177 3/26/2021
1.0.0-beta0007 189 3/24/2021
1.0.0-beta0006 193 3/23/2021
1.0.0-beta0005 194 3/22/2021
1.0.0-beta0004 193 3/19/2021
1.0.0-beta0003 167 3/19/2021
1.0.0-beta0002 185 3/19/2021
1.0.0-beta0001 176 3/19/2021
0.17.1 183 4/6/2021
0.17.1-beta0001 163 4/5/2021
0.17.0 241 3/24/2021
0.16.0 198 3/23/2021
0.15.0 410 3/8/2021
0.15.0-alpha0038 199 3/8/2021
0.14.0 222 3/5/2021
0.14.0-alpha0003 161 3/5/2021
0.13.0 207 3/3/2021
0.13.0-alpha0001 166 3/3/2021
0.12.0 296 2/18/2021
0.12.0-typescript0001 177 2/18/2021
0.12.0-publish-typescri0001 158 2/18/2021
0.12.0-alpha0018 164 2/18/2021
0.11.0 205 2/17/2021
0.11.0-alpha0003 154 2/17/2021
0.10.1 206 2/15/2021
0.10.0 188 2/15/2021
0.10.0-alpha0011 145 2/15/2021
0.10.0-alpha0005 156 2/15/2021
0.9.0 251 1/24/2021
0.9.0-alpha0013 216 1/24/2021
0.9.0-alpha0006 228 1/3/2021
0.9.0-alpha0003 218 12/8/2020
0.8.1 265 1/3/2021
0.8.0 333 12/8/2020
0.8.0-beta0001 193 12/8/2020
0.8.0-alpha0005 222 11/25/2020
0.7.1 263 11/25/2020
0.7.0 250 11/25/2020
0.7.0-beta0001 202 11/25/2020
0.7.0-alpha0002 211 11/24/2020
0.6.0-beta0001 242 11/24/2020
0.6.0-alpha0005 224 11/24/2020
0.6.0-alpha0001 218 11/23/2020
0.5.2 1,035 11/24/2020
0.5.1 257 11/23/2020
0.5.0 238 11/19/2020
0.4.0 238 11/12/2020
0.3.0-beta0001 243 11/12/2020
0.3.0-alpha0019 196 11/19/2020
0.3.0-alpha0010 230 11/12/2020
0.3.0-alpha0004 235 11/12/2020
0.2.0 255 11/12/2020
0.2.0-beta0003 255 11/12/2020
0.2.0-beta0002 249 11/12/2020
0.2.0-beta0001 240 11/11/2020
0.1.0 287 11/11/2020
0.1.0-beta0002 241 11/11/2020
0.1.0-beta0001 233 11/11/2020
0.1.0-alpha0236 265 11/11/2020
0.1.0-alpha0116 222 11/11/2020
0.1.0-alpha0112 242 11/11/2020
0.1.0-alpha0097 224 11/11/2020
0.1.0-alpha0091 225 11/11/2020
0.1.0-alpha0090 232 11/10/2020
0.1.0-alpha0089 241 11/10/2020
0.1.0-alpha0088 252 11/10/2020
0.1.0-alpha0087 255 11/10/2020
0.1.0-alpha0086 251 11/10/2020
0.1.0-alpha0085 259 11/10/2020
0.1.0-alpha0084 239 11/10/2020
0.1.0-alpha0083 239 11/10/2020
0.1.0-alpha0082 289 11/9/2020
0.1.0-alpha0081 293 11/9/2020
0.1.0-alpha0080 298 11/9/2020
0.1.0-alpha0079 255 11/7/2020
0.1.0-alpha0077 418 11/6/2020
0.1.0-alpha0076 409 11/6/2020
0.1.0-alpha0074 324 11/6/2020
0.1.0-alpha0071 253 11/6/2020
0.0.1-ci-20201106.2 184 11/6/2020
0.0.1-ci-20201106.1 140 11/6/2020
0.0.1-ci-20201105.7 192 11/5/2020
0.0.1-ci-20201105.6 199 11/5/2020
0.0.1-ci-20201105.5 200 11/5/2020
0.0.1-ci-20201105.4 200 11/5/2020
0.0.1-ci-20201105.3 142 11/5/2020
0.0.1-ci-20201105.2 155 11/5/2020
0.0.1-ci-20201105.1 139 11/5/2020
0.0.1-ci-20201104.2 149 11/4/2020
0.0.1-ci-20201104.1 153 11/4/2020
0.0.1-ci-20201030.5 152 10/30/2020
0.0.1-ci-20201030.4 153 10/30/2020
0.0.1-ci-20201030.3 174 10/30/2020
0.0.1-ci-20201030.2 147 10/30/2020
0.0.1-ci-20201030.1 143 10/30/2020
0.0.1-ci-20201029.3 141 10/29/2020
0.0.1-ci-20201029.2 167 10/29/2020
0.0.1-ci-20201029.1 155 10/29/2020
0.0.1-ci-20201028.1 132 10/28/2020
0.0.1-ci-20201027.1 159 10/27/2020
0.0.1-ci-20201026.2 175 10/26/2020
0.0.1-ci-20201026.1 130 10/26/2020
0.0.1-ci-20201023.2 168 10/23/2020
0.0.1-ci-20201023.1 156 10/23/2020
0.0.1-ci-20201022.1 144 10/22/2020
0.0.1-ci-20201008.1 136 10/8/2020
0.0.1-ci-20201005.1 185 10/5/2020
0.0.1-ci-20200407.1 186 4/7/2020
0.0.1-ci-20200406.3 186 4/6/2020
0.0.1-ci-20200406.2 207 4/6/2020
0.0.1-ci-20200406.1 200 4/6/2020
0.0.1-ci-20200403.5 180 4/3/2020
0.0.1-ci-20200403.4 196 4/3/2020
0.0.1-ci-20200403.3 207 4/3/2020
0.0.1-ci-20200403.2 191 4/3/2020
0.0.1-ci-20200403.1 197 4/3/2020
0.0.1-ci-20200402.2 192 4/2/2020
0.0.1-ci-20200402.1 220 4/2/2020