-
Notifications
You must be signed in to change notification settings - Fork 287
/
yandex.html
62 lines (53 loc) · 1.76 KB
/
yandex.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<html>
<head>
<title>L.Yandex example</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<script src="https://api-maps.yandex.ru/2.1/?lang=en_RU&apikey=<your API-key>" type="text/javascript"></script>
<script src="../layer/tile/Yandex.js"></script>
<style>
.leaflet-bottom { bottom: 20px }
.leaflet-control-attribution { margin-bottom: -10px !important }
</style>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script>
var center = [67.6755, 33.936];
var map = L.map('map', {
center: center,
zoom: 10,
zoomAnimation: true
});
map.attributionControl
.setPosition('bottomleft')
.setPrefix('');
function traffic () {
// https://tech.yandex.ru/maps/jsbox/2.1/traffic_provider
var actualProvider = new ymaps.traffic.provider.Actual({}, { infoLayerShown: true });
actualProvider.setMap(this._yandex);
}
var baseLayers = {
'Yandex map': L.yandex() // 'map' is default
.addTo(map),
'Yandex map + Traffic': L.yandex('map')
.on('load', traffic),
'Yandex satellite': L.yandex({ type: 'satellite' }), // type can be set in options
'Yandex hybrid': L.yandex('hybrid'),
'OSM': L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
})
};
var overlays = {
'Traffic': L.yandex('overlay')
.on('load', traffic)
};
L.control.layers(baseLayers, overlays, {collapsed: false}).addTo(map);
var marker = L.marker(center, { draggable: true }).addTo(map);
map.locate({ setView: true, maxZoom: 14 })
.on('locationfound',function (e) {
marker.setLatLng(e.latlng);
});
</script>
</body>
</html>