var mapElement = document.getElementById('map');
// Create the Google Map using our element and options defined above
var map = new google.maps.Map(mapElement, mapOptions);
var w = (150 / 3);
var h = (215 / 3);
// if (window.matchMedia("(min-width: 450px)").matches) {
// w = (548 / 4);
// h = (326 / 4);
// }
// var's also add a marker while we're at it
var image = {
url: 'https://pravo-element.com/wp-content/themes/pravo/img/marker.svg',
size: new google.maps.Size(w, h),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(w / 2, h),
scaledSize: new google.maps.Size(w, h),
};
var marker = new google.maps.Marker({
position: {
lat: 46.4886430,
lng: 30.7388162
},
map: map,
//animation: google.maps.Animation.DROP,
icon: image,
optimized: false,
});
function setMapAddress (json) {
map.setCenter({lat: json['map']['lat'], lng: json['map']['lng']});
marker.setPosition({lat: json['map']['lat'], lng: json['map']['lng']});
map.setZoom(json['map']['zoom']);
}
document.querySelectorAll('[data-address]').forEach((elem, i, list) => {
let json = JSON.parse(elem.dataset.address);
if (i == 0) {
setMapAddress(json)
}
elem.addEventListener('click', e => {
e.preventDefault()
list.forEach(elem => elem.classList.remove('active'))
elem.classList.add('active');
document.querySelector('.blog-cats__address').innerHTML = json['address'];
setMapAddress(json)
//document.querySelector('[data-dir-link]').setAttribute('href', 'http://www.google.com/maps/place/'+json['lat']+','+json['lng'])
})
})
}