Map Connection
Page Preparation
To connect the map, you need to complete several steps:
- Get an access key to the "Visicom Tiles" and "Visicom Data API" services.
- In the
headsection of the page, connect the Leaflet CSS files.
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css">
- Include the loading of the "engine" itself, preferably before the closing
bodytag.
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
- Define a
divin which the map will be displayed. This element must have width and height.
<div id="map" style="width: 100%; height: 400px;">
Map Initialization
To display our tiles, you need to insert the following code between script tags:
document.addEventListener('DOMContentLoaded', function () {
var map = new L.Map('map', {
center: new L.LatLng(50.455002, 30.511284),
zoom: 9,
layers: [
new L.TileLayer('https://tms{s}.visicom.ua/2.0.0/planet3/base/{z}/{x}/{y}.png?key=YOUR_API_KEY', {
attribution: 'Map data © "<a href="https://api.visicom.ua/">Visicom</a>" JSC',
maxZoom: 19,
subdomains: '123',
tms: true
})
]
});
});
Don't forget to replace YOUR_API_KEY with the key obtained during registration. For more details about the Leaflet library, see the website http://leafletjs.com.
For convenient search on the map, we recommend connecting our search widget.
Complete Example
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Visicom Example</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
</head>
<body>
<div id="map" style="width: 100%; height: 400px;"></div>
<script>
document.addEventListener('DOMContentLoaded', function () {
var map = new L.Map('map', {
center: new L.LatLng(50.455002, 30.511284),
zoom: 9,
layers: [
new L.TileLayer('https://tms{s}.visicom.ua/2.0.0/planet3/base/{z}/{x}/{y}.png?key=YOUR_API_KEY', {
attribution: 'Map data © "<a href="https://api.visicom.ua/">Visicom</a>" JSC',
maxZoom: 19,
subdomains: '123',
tms: true
})
]
});
});
</script>
</body>
</html>