Map JS API
Display a popup when the user click on an item
This example introduces of how to use the ShowPopupAtItem API function to show a customized popup.
<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.ItemClicked.on(OnClicked); addGeoJSON(); } function OnClicked(e) { // Get the item clicked var item = map.GetItemById(e.id); var html = "This is my popup
- Name : " + map.GetItemProperty(e.id, "name") + "
- Temperature : " + map.GetItemProperty(e.id, "Temperature") + "
- ...
Help Guide Powered by Documentor