Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (13.1k points)
edited by

I was trying to display the map. But the code which I was using gives an error:

TypeError: atlas.map is not a constructor

This is the code I am using:

<html>

 <head>

    <!-- Load in the Azure Maps Web SDK - Using CSS and JS -->

    <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>

   <!-- Add a reference to the Azure Maps Services Module JavaScript file. -->

   <script src="https://atlas.microsoft.com/sdk/javascript/service/2/atlas-service.min.js"></script>

  </head>

<body>

  <div id="theMap"></div>

    <script type="text/javascript">

      map = new atlas.map('theMap', {

        // Only allow one copy of the world be rendered when zoomed out.

        renderWorldCopies: false,

        language: 'en-US',

        center: [-122.3353, 47.6038],

        zoom: 12,

        view: 'auto',

        style: 'road',

        authOptions: {

            authType: 'subscriptionKey',

            subscriptionKey: 'mySubKey',

            getToken: function(resolve, reject, map) {

                fetch(url).then(function(response) {

                    return response.text();

                }).then(function(token) {

                    resolve(token);

                });

            }

        }

    });

    // Wait until the map resources are ready.

    map.events.add('ready', function () {

    });

</script>

</body>

</html>

Can anyone help me to rectify this error?

1 Answer

0 votes
by (26.7k points)
edited by

Basically, the line which consists:

 map = new atlas.map('theMap', {

Should be like this:

 map = new atlas.Map('theMap', {

"M" should be in Capital letter.

I hope this will help.

Want to become an Azure expert? join Azure Master Program now!!

Related questions

+1 vote
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...