map.js
4.61 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
$(document).ready(function() {
initialize()
function initialize() {
var zooms = 12;
var paramsList = $('.all-shops-cord');
zooms = +(paramsList.attr('param-zoom'));
//console.log(zooms)
var autoCenter = paramsList.data('autocentr');
var startLat = 50.435;
var startLng = 30.60;
if(autoCenter) {
var newStartI = 0;
var newStartLat = 0;
var newStartLng = 0;
$(paramsList).find('span').each(function() {
newStartI ++;
newStartLat = newStartLat + (+($(this).data('lat')));
})
startLat = newStartLat / newStartI;
newStartI = 0;
$(paramsList).find('span').each(function() {
newStartI ++;
newStartLng = newStartLng + (+($(this).data('lng')));
})
startLng = newStartLng / newStartI;
}
var start_position = new google.maps.LatLng(startLat, startLng);
var styles = [
{
stylers: [
{saturation: -100}
]
}
];
var settings = {
styles: styles,
zoom: zooms,
scrollwheel: false,
center: start_position,
mapTypeControl: true,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: false,
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
scaleControl: true,
streetViewControl: true,
rotateControl: true,
zoomControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
var image1 = new google.maps.MarkerImage('images-new/markers/marker-we-1.png', new google.maps.Size(34, 48), new google.maps.Point(0, 0), new google.maps.Point(16, 35));
var markers = [];
$(paramsList).find('span').each(function() {
var newLat = $(this).data('lat');
var newLng = $(this).data('lng');
var newName = $(this).text();
var marker = new google.maps.Marker({
position: new google.maps.LatLng(newLat, newLng),
map: map,
title: newName,
icon: image1
});
markers.push(marker);
}
);
var clusterStyles = [
{
url: 'images-new/markers/clasters.png',
height: 36,
width: 36
}
];
markerClusterer = new MarkerClusterer(map, markers, {
maxZoom: 10,
gridSize: 100,
minimumClusterSize:1,
styles: clusterStyles
});
}
$('.cities-tile .addCity i').click(function () {
$(this).parent().parent().addClass('vis');
})
$('.hidden_shops ul li').click(function () {
$('.hidden_shops ul li').removeClass('active');
$(this).addClass('active');
var newNameActiveCity = $(this).find('span.s_').text();
var newPhonesActiveCity = $(this).find('span.s_').text();
var newPhonesAdressGraph = $(this).find('.p_').html();
$(this).parents('.hidden_shops').parent().parent().removeClass('vis')
$(this).parents('.hidden_shops').parent().find('i').html(newNameActiveCity);
$('.phone-graph-map-wr').empty().html(newPhonesAdressGraph);
var newCordActiveCity = $(this).find('.p_').find('.adress-map-wr');
// console.log(newCordActiveCity.length )
$('.all-shops-cord').empty();
var newZooms = 17 ;
if(newCordActiveCity.length > 1) {
newZooms = 12 ;
newCordActiveCity.each(function () {
$('.all-shops-cord').append($(this).html())
})
} else {
$('.all-shops-cord').html(newCordActiveCity.html());
}
$('.all-shops-cord').attr('param-zoom',newZooms);
initialize();
})
$('body').on('click', '.adress-map-wr', function () {
if($(this).parents('.phone-graph-map-wr').find('.adress-map-wr').length > 1 || $(this).find('span').hasClass('first-click-adress')) {
$('.adress-map-wr span').removeClass('active');
$(this).find('span').addClass('active');
$('.all-shops-cord').attr('param-zoom',18);
$('.all-shops-cord').html( $(this).html());
initialize();
}
})
})