Docs

Map JS API

Unauthorized access #

Initialize the map into an HTML element using the JS API. To initialize the map, it’s mandatory to provide a valid Map Key AND valid credentials (User/Pass or api key) in the constructor (see the source code for details).

<html>
<head>
    
    <script src="https://rasters.io/maps/v0.8.0/rasters.map.min.js"></script>
    <link rel="stylesheet" href="https://rasters.io/maps/v0.8.0/rasters.css" />

    <style>
        html, body {
            height: 100%;
            -ms-touch-action: none;
        }       
    </style>
</head>
<body>
    <script>       
        var map;        
        var WrongKey = "Enter your Apikey here";
                              
        Rasters.Map.OnReady = function () {
              map = new Rasters.Map({
                container: 'Map', // container id
                url: 'https://api.rasters.io/', 
                mapKey: '',
                authenticationMode: Rasters.AuthenticationMode.MapToken,               
                token: WrongKey
            });
         
   map.OnUnauthorized = function () { alert("Unauthorized"); }; 
           
        }

 function OnConnectHander() {
            map.SetPosition(-71.2170425, 46.810457, 10);    
        }       
    </script>

  <div id="Map"></div>       
     
</body>
</html>
Help Guide Powered by Documentor
Suggest Edit