Use legends in azure map contol older version

Satyam Chauhan 547 Reputation points
2024-05-28T10:55:17.4833333+00:00

Hi,

I am using azure maps control version - 2.1.8 and I want to show a customized legend for my map. I have seen the example provided in azure map samples - https://samples.azuremaps.com/?search=legend&sample= which uses - new atlas.control.LegendControl, but on using it, I get the following error - Property 'LegendControl' does not exist on type 'typeof control'.

Please share some examples how can I use this in older version of azure-map-control package. Due to restrictions I cannot upgrade the package version.

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
716 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. rbrundritt 17,981 Reputation points Microsoft Employee
    2024-05-28T15:32:41.0933333+00:00

    That legend control was created for version 2 so it should work. Note that it is not a built-in part of the Azure Maps control, but an open-source module you can host and load into your app. Be sure to download the source files from the dist folder from here: https://github.com/Azure-Samples/azure-maps-layer-legend Then host these as js/css files in your app, load them into your page after the script tag for the Azure Maps control, and it will add itself to the atlas namespace.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.