Docs

Map JS API

See how to add a marker to a specific address #

Use the Rasters Map JS API to geocode an address and display results on the map. The following JSON is returned :

{
  [
    boundingBox,
    displayName,
    importance,
    lat,
    lon,
    placeId
  ],
  [
     other result...
  ]
}

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

</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);

      map.GeoCode("1260 boulevard lebourgneuf, qc", function (results, status) {
      if (status === "OK") {
        map.AddMapItems({
           "type": "Feature",
           "id": "search point",
              "properties": {
              "device_name": "Point1",
              "text": results[0].displayName,          
              "style.color": "#0000ff",
              "style.icon": "star"
           },
           "geometry": {
              "type": "Point",
              "coordinates": [results[0].lon, results[0].lat]
           }
        }, "", false, false); // AddMapItems
      }
     });
   }   

</script>

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