2gis-maps
Version:
Interactive 2GIS maps API, based on Leaflet
98 lines (83 loc) • 4.8 kB
HTML
<h2 id="work-with wkt">Work with WKT</h2><p><dl class="api-incut"><ul class="page-contents"><li><a href="#description">Description</a></li><li><a href="#display-of simple vector layers">Display of simple vector layers</a></li><li><a href="#display-of complex vector layers">Display of complex vector layers</a></li></ul></dl></p>
<h3 id="description">Description</h3><p>The following is an example of working with WKT.
For more information go to the <a href="/doc/maps/en/manual/dg-wkt">WKT</a> section of documentation.</p>
<h3 id="display-of simple vector layers">Display of simple vector layers</h3><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,
coord1 = 'POLYGON((82.91699 55.042136, 82.917522 55.040187, 82.918063 55.040235, 82.917540 55.042184,82.91699 55.042136))',
coord2 = 'LINESTRING(82.91799 55.043136, 82.918522 55.041187, 82.919063 55.041235)',
coord3 = 'POINT(82.914 55.042136)';
map = DG.map('map', {
center: [55.042136, 82.91699],
zoom: 16
});
DG.Wkt.geoJsonLayer(coord1).addTo(map);
DG.Wkt.geoJsonLayer(coord2).addTo(map);
DG.Wkt.geoJsonLayer(coord3).addTo(map);
})
</script>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>Display of simple vector layers</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,
coord1 = 'POLYGON((82.91699 55.042136, 82.917522 55.040187, 82.918063 55.040235, 82.917540 55.042184,82.91699 55.042136))',
coord2 = 'LINESTRING(82.91799 55.043136, 82.918522 55.041187, 82.919063 55.041235)',
coord3 = 'POINT(82.914 55.042136)';
map = DG.map('map', {
center: [55.042136, 82.91699],
zoom: 16
});
DG.Wkt.geoJsonLayer(coord1).addTo(map);
DG.Wkt.geoJsonLayer(coord2).addTo(map);
DG.Wkt.geoJsonLayer(coord3).addTo(map);
})
</script>
</body>
</html>
</code></pre><h3 id="display-of complex vector layers">Display of complex vector layers</h3><p><div id="map1" style="width: 100%; height: 400px;"></div></p>
<script>
DG.then(function() {
var map = DG.map('map1', {
center: [55.041836, 82.91699],
zoom: 16
});
DG.Wkt.geoJsonLayer('MULTIPOLYGON(((82.91699 55.042136, 82.917522 55.040187, 82.918063 55.040235, 82.917540 55.042184,82.91699 55.042136)), ((82.91599 55.041136, 82.916522 55.039187, 82.917063 55.039235, 82.916540 55.041184,82.91599 55.041136)))').addTo(map);
DG.Wkt.geoJsonLayer('MULTILINESTRING((82.91799 55.043136, 82.918522 55.041187, 82.919063 55.041235), (82.91899 55.044136, 82.919522 55.042187, 82.920063 55.042235))').addTo(map);
DG.Wkt.geoJsonLayer('MULTIPOINT(82.914 55.042136, 82.915 55.043136, 82.915 55.042136, 82.914 55.043136)').addTo(map);
});
</script>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>Display of compound vector layers</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,
coord1 = 'MULTIPOLYGON(((82.91699 55.042136, 82.917522 55.040187, 82.918063 55.040235, 82.917540 55.042184,82.91699 55.042136)), ((82.91599 55.041136, 82.916522 55.039187, 82.917063 55.039235, 82.916540 55.041184,82.91599 55.041136)))',
coord2 = 'MULTILINESTRING((82.91799 55.043136, 82.918522 55.041187, 82.919063 55.041235), (82.91899 55.044136, 82.919522 55.042187, 82.920063 55.042235))',
coord3 = 'MULTIPOINT(82.914 55.042136, 82.915 55.043136, 82.915 55.042136, 82.914 55.043136)';
map = DG.map('map', {
center: [55.041836, 82.91699],
zoom: 16
});
DG.Wkt.geoJsonLayer(coord1).addTo(map);
DG.Wkt.geoJsonLayer(coord2).addTo(map);
DG.Wkt.geoJsonLayer(coord3).addTo(map);
});
</script>
</body>
</html>
</code></pre>