Obtaining an Azure Maps subscription key
Before connecting to Azure Maps, you must first set up authentication. LuciadLightspeed supports the Shared Key authentication method. It requires you to pass in a subscription key in requests to the Azure Maps REST API. The Azure Maps portal allows you to create an Azure Maps account and one or more Azure Maps subscription keys.
To get started with Azure Maps, you can request a key to try it for free:
-
Go to https://www.microsoft.com/en-us/maps/azure/get-started.
-
Click "Start for free".
-
Click "Try Azure for free".
-
Sign in with your Windows Live ID, or create one.
-
In the Azure Maps portal, click "Azure Maps Accounts". If you don’t see it, you can use the search field to find it.
-
Click "Create".
-
Fill in the Instance details, such as name and region.
-
Click on "Review + create".
-
In the account page, click "View authentication". This shows a primary and secondary key that can be used for Shared Key authentication.
Visualizing the data on the map
Visualizing Azure Maps data on a GXY view requires the same two steps as the majority of the formats:
-
Decode the data into an
ILcdModelusing anILcdModelDecoder. -
Create an
ILcdGXYLayerfor theILcdModeland add it to theILcdGXYView
In addition to those common visualization steps, the Azure Maps terms of use from Microsoft require you to show copyright information on the map:
// Create the Azure maps data source to specify what kind of data we want
TLcdAzureMapsDataSource dataSource =
TLcdAzureMapsDataSource.newBuilder()
.subscriptionKey(subscriptionKey)
.mapStyle(ELcdAzureMapsMapStyle.IMAGERY)
.build();
// Decode the data source into a model
ILcdModelDecoder decoder = new TLcdCompositeModelDecoder(
TLcdServiceLoader.getInstance(ILcdModelDecoder.class)
);
ILcdModel model = decoder.decodeSource(dataSource);
// Create an async layer for it
ILcdGXYLayer layer = new TLcdAzureMapsGXYLayerFactory().createGXYLayer(model);
layer = ILcdGXYAsynchronousLayerWrapper.create(layer);
// Add the layer to the view
view.addGXYLayer(layer);
// The Azure Maps license agreement requires to display copyright information on the map.
TLcdAzureMapsGXYCopyrightIcon copyrightIcon = new TLcdAzureMapsGXYCopyrightIcon(view);
copyrightIcon.setAlignment(ELcdHorizontalAlignment.RIGHT);
overlayPanel.add(copyrightIcon.asComponent(), TLcdOverlayLayout.Location.SOUTH_WEST);
// While the Azure Maps license agreement doesn't mention the need to display a logo icon,
// the official Azure Maps sample applications do it by default.
TLcdAzureMapsLogoIcon logoIcon = new TLcdAzureMapsLogoIcon(view);
overlayPanel.add(logoIcon.asComponent(), TLcdOverlayLayout.Location.SOUTH_WEST);
This results in an Azure Maps layer with default styling.
|
This code snippet uses the The actual model decoder class responsible for decoding Azure Maps data sources is the
|