Map JS API
Display a simple map
Initialize the map into 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 MapToken) 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 MapToken = "Enter your MapToken here"; Rasters.Map.OnReady = function () { map = new Rasters.Map({ container: 'Map', // container id url: 'https://api.rasters.io/', mapKey: "", authenticationMode: Rasters.AuthenticationMode.MapToken, token: MapToken }); // Here an example to create a map with credential rather than API KEY // var Username = "Enter your Username here"; // var Password = "Enter your Password here"; // Rasters.Map.OnReady = function () { // map = new Rasters.Map({ // container: 'Map', // container id // url: 'https://api.rasters.io/', // mapKey: mapKey, // authenticationMode: Rasters.AuthenticationMode.UserPassword, // username: 'Enter your Username here', // password: 'Enter your Password here' // }); map.OnReady = OnConnectHander; } function OnConnectHander() { map.SetPosition(-71.2170425, 46.810457, 10); } </script> <div id="Map"></div> </body> </html>
Help Guide Powered by Documentor