$(document).ready(function() {
$('.spoiler_links').click(function() {
$(this).parent().children('div.spoiler_body').toggle('normal');
return false;
});
var x = document.getElementsByClassName('spoiler_links'),
xx = document.getElementsByClassName('destination'),
sp = document.getElementsByClassName('spoiler_body');
$(x).each(function( index ) {
if (this) {sp[index].setAttribute('style', 'display:none;');}
$(this).attr('id', index);
$('#' + index).prependTo(xx[index]);
});
});
const GeoUrl = 'https://ipinfo.io/json';
function httpGet(url) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = function() {
if (this.status == 200) {
resolve(this.response);
} else {
var error = new Error(this.statusText);
error.code = this.status;
reject(error);
}
};
xhr.onerror = function() {
reject(new Error("Network Error"));
};
xhr.send();
});
}
httpGet(GeoUrl)
.then(response => {
let data = JSON.parse(response);
return data;
})
.then(data => httpGet("http://api.openweathermap.org/data/2.5/weather?q="+ data.city+"&units=metric&APPID=061f24cf3cde2f60644a8240302983f2"))
.then(data => {
console.log(data);
return
})
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d46773.46179010857!2d75.0502236986581!3d42.88674406324874!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x389c041f79348bad%3A0x23897ba069e66c57!2z0JjQstCw0L3QvtCy0LrQsCwg0JrQuNGA0LPQuNC30LjRjw!5e0!3m2!1sru!2sru!4v1491857183017" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
<script src="//api-maps.yandex.ru/2.0/?load=package.standard&lang=ru-RU" type="text/javascript"></script>
$(document).ready(function($) {
ymaps.ready(init);
function init() {
var geolocation = ymaps.geolocation;
if (geolocation) {
$text_city = geolocation.country + ', ' + geolocation.region + ', ' + geolocation.city;
//console.log($text_city);
$("#city0").val($text_city);
$("#city1").val($text_city);
$("#city2").val($text_city);
$("#city3").val($text_city);
$("#city4").val($text_city);
$("#city_call").val($text_city);
$("#city_modreserve").val($text_city);
$("#city_reserve").val($text_city);
} else {
console.log('Не удалось установить местоположение');
}
}
});
<button id="show">Показать на карте</button>
<div id="map" style="width: 300px; height: 300px"></div>
ymaps.ready(init);
var myMap;
function init(){
myMap = new ymaps.Map ("map", {
center: [55.76, 37.64],
zoom: 7
})}
var el = document.getElementById("show");
el.addEventListener("click", showBal, false);
function showBal(){
myMap.balloon.open(myMap.getCenter(), { content: 'Hello Yandex!' }, { closeButton: true });
}