/* ----------------------------------------------------------------------------------------------------- MAP*/
$("#select__city").change(function () {
val = $('#select__city :selected').val();
$('.city__info').removeClass('active');
$('.' + val).addClass('active');
$.each(map.markers, function() {
this.setVisible(false);
if (this['category'] == val) {
this.setVisible(true);
}
});
});
$('#select__city').change(function(e) {
$('#'+$(this).val()).click();
});
var markerArray = [];
function moveMap(address) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var coords = {
lat: results[0].geometry.location.lat(),
lng: results[0].geometry.location.lng()
}
map.setCenter(coords);
map.setZoom(11);
// console.log(coords);
}
});
}
function setMarkers(arr) {
var geocoder = new google.maps.Geocoder();
var image = new google.maps.MarkerImage(
'/bitrix/templates/abdi/images/template/map__ico.png',
new google.maps.Size(52, 52),
new google.maps.Point(0,0),
new google.maps.Point(26, 26)
);
var imageActive = new google.maps.MarkerImage(
'/bitrix/templates/abdi/images/template/map__ico-active.png',
new google.maps.Size(106, 106),
new google.maps.Point(0,0),
new google.maps.Point(53, 53)
);
for (var i = 0; i < arr.length; i++){
var iPerSec = 2;
var sec = (i-i%iPerSec)/iPerSec*1000;
// console.log(sec);
setTimeout(function (address) {
geocoder.geocode({ 'address': address }, function (results, status) {
// console.log(status);
if (status == google.maps.GeocoderStatus.OK) {
var coords = {
lat: results[0].geometry.location.lat(),
lng: results[0].geometry.location.lng()
}
// console.log(results);
var marker = new google.maps.Marker({
title: results[0].address_components[0].short_name,
position: coords,
map: map,
icon: image,
animation: google.maps.Animation.DROP
});
marker.addListener('click', function() {
$('.markers #'+this.getTitle().replace(/([ /])/g, '_') ).click();
for (var i = 0; i < markerArray.length; i++) {
markerArray[i].setIcon(image);
}
this.setIcon(imageActive);
var city = this.getTitle();
$(this).addClass('active');
$('.map__popup .item').hide();
$('.map__popup').find($('[data-city ="'+ city.replace(/([ /])/g, '_')+'"]')).fadeIn('slow');
});
// map.setCenter(marker.getPosition());
markerArray.push(marker);
} else {
// alert('GMAP_ERROR!');
}
});
},1000+700*i,arr[i][0]);
}
};
var map;
var styleArray = [
{
featureType: "all",
stylers: [
{ saturation: -100 }
]
},{
featureType: "road.arterial",
elementType: "geometry",
stylers: [
{ saturation: -100 }
]
},{
featureType: "poi.business",
elementType: "labels",
stylers: [
{ visibility: "off" }
]
}
];
// if($('#mymap').length){
// function initMap() {
map = new google.maps.Map(document.getElementById('mymap'), {
center: {lat: 49, lng: 80},
zoom: 5,
styles: styleArray,
mapTypeControl: false,
scrollwheel: false
// disableDefaultUI: true
});
setMarkers(cities);
$('.map__popup .item').each(function(id, item){
if(id!=0){
$(item).hide();
}
});
$('#select__city').change();
// }
// }
Оно?