2gis-maps
Version:
Interactive 2GIS maps API, based on Leaflet
76 lines (72 loc) • 3.44 kB
HTML
<h2 id="control-elements">Control elements</h2><p><dl class="api-incut"><ul class="page-contents"><li><a href="#description">Description</a></li><li><a href="#hide-the default control elements">Hide the default control elements</a></li><li><a href="#the-display of control elements in different parts of the map">The display of control elements in different parts of the map</a></li></ul></dl></p>
<h3 id="description">Description</h3><p>The following are examples of adding, placing, and working with control elements. For more information about the work
with control elements use the <a href="/doc/maps/en/manual/controls">Controls</a> section of documentation.</p>
<h3 id="hide-the default control elements">Hide the default control elements</h3><p>If you need to obtain a "clear" map, with no extra control elements, then the following example will help you:</p>
<script src="https://maps.api.2gis.ru/2.0/loader.js"></script>
<div id="map" style="width: 100%; height: 400px;"></div>
<script>
DG.then(function() {
var map = DG.map('map', {
center: [54.98, 82.89],
zoom: 13,
fullscreenControl: false,
zoomControl: false
});
});
</script>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>Hide control elements by default</title>
<script src="https://maps.api.2gis.ru/2.0/loader.js"></script>
</head>
<body>
<div id="map" style="width: 100%; height: 400px;"></div>
<script>
DG.then(function() {
var map = DG.map('map', {
center: [54.98, 82.89],
zoom: 13,
fullscreenControl: false,
zoomControl: false
});
});
</script>
</body>
</html>
</code></pre><h3 id="the-display of control elements in different parts of the map">The display of control elements in different parts of the map</h3><p><div id="map1" style="width: 100%; height: 400px;"></div></p>
<script>
DG.then(function() {
var map = DG.map('map1', {
center: [54.98, 82.89],
zoom: 13
});
DG.control.location({position: 'bottomright'}).addTo(map);
DG.control.scale().addTo(map);
DG.control.ruler({position: 'bottomleft'}).addTo(map);
DG.control.traffic().addTo(map);
});
</script>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>Dislay of control elements in different parts of the map</title>
<script src="https://maps.api.2gis.ru/2.0/loader.js"></script>
</head>
<body>
<div id="map" style="width: 100%; height: 400px;"></div>
<script>
DG.then(function() {
var map = DG.map('map', {
center: [54.98, 82.89],
zoom: 13
});
DG.control.location({position: 'bottomright'}).addTo(map);
DG.control.scale().addTo(map);
DG.control.ruler({position: 'bottomleft'}).addTo(map);
DG.control.traffic().addTo(map);
});
</script>
</body>
</html>
</code></pre>