-
Notifications
You must be signed in to change notification settings - Fork 27
/
main.js
46 lines (40 loc) · 1.24 KB
/
main.js
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
/**
* LMD require.js() and shortcuts example
*/
function renderMap() {
var $map = $('#map');
// @see http://api.yandex.ru/maps/jsbox/geolocation_ip
ymaps.ready(function () {
// IP based geolocation
var geolocation = ymaps.geolocation,
coords = [geolocation.latitude, geolocation.longitude],
myMap = new ymaps.Map($map[0], {
center: coords,
zoom: 10
});
myMap.geoObjects.add(
new ymaps.Placemark(
coords,
{
// add balloon
balloonContentHeader: geolocation.country,
balloonContent: geolocation.city,
balloonContentFooter: geolocation.region
}
)
);
});
}
$(function () {
var $button = $('.b-button');
$button.click(function () {
$button.text('Loading...');
// using shortcuts
// yandexMapsApi -> //api-maps.yandex.ru/2.0-stable/?load=package.standard&lang=ru-RU
require.js("yandexMapsApi", function (status) {
console.log(status ? 'Js Loaded' : 'Fail to load');
$button.remove();
renderMap();
});
});
});