Docs

Map JS API

Set all properties to change the polygon style #

Here is an example how to set style properties for a polygon.

<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 
            });
         
        map.OnReady = OnConnectHander;           
   }

  function OnConnectHander() {
            map.SetPosition(-71.2170425, 46.810457, 10);    
           addGeoJSON();
        }       

function addGeoJSON() { 
    var geoJson = { 
       "type": "Feature",
       "id":"p123",
       "properties": {
         "name": "Polygon1",
         "style.line-color": "#008866",
         "style.color": "rgba(255,255,0,0.5)",
         "style.line-width": 10,
         "style.fill-opacity": 0.5
       },
    "geometry": {
      "type": "Polygon",
      "coordinates": [[
        [-71.23, 46.466],
        [-70.23, 46.466],
        [-70.23, 47.466],
        [-71.23, 47.466],
        [-71.23, 46.466]
      ]]
    }
 }; 

      // Set the last parameter to true (isLocked)
      map.AddMapItems(geoJson, "", false, true);

</script>

  <div id="Map" style='width: 100%; height: 100%;'></div>
     
</body>
</html>
Help Guide Powered by Documentor
Suggest Edit