-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.js
79 lines (57 loc) · 3.38 KB
/
map.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
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
$(function() {
var marker = [], infowindow = [], map, image = 'img/marker.png';
function addMarker(location,name,contentstr){
marker[name] = new google.maps.Marker({
position: location,
map: map,
icon: image
});
marker[name].setMap(map);
infowindow[name] = new google.maps.InfoWindow({
content:contentstr
});
google.maps.event.addListener(marker[name], 'click', function() {
infowindow[name].open(map,marker[name]);
});
}
function moveto_region(location,zoom_level) {
map.setZoom(zoom_level);
map.setCenter(location);
$('body, html').animate({'scrollTop': $('#map-canvas').offset().top - $('header').outerHeight()});
}
$('.marker').on('click', function(){
var coord1 = $(this).attr('data-lng');
var coord2 = $(this).attr('data-lat');
var location = new google.maps.LatLng(coord2,coord1);
moveto_region(location, 18);
});
function initialize() {
var lat = $('#map-canvas').attr("data-lat");
var lng = $('#map-canvas').attr("data-lng");
var myLatlng = new google.maps.LatLng(lat,lng);
var setZoom = parseInt($('#map-canvas').attr("data-zoom"));
var styles = [{"featureType":"all","elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#000000"},{"lightness":40}]},{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#000000"},{"lightness":16}]},{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"weight":1.2}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":21}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":16}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":17}]}];
var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"});
var mapOptions = {
zoom: setZoom,
scrollwheel: false,
center: myLatlng,
disableDefaultUI: true
};
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
map.mapTypes.set('map_style', styledMap);
map.setMapTypeId('map_style');
$('.addresses-block a.marker').each(function(){
var mark_lat = $(this).attr('data-lat');
var mark_lng = $(this).attr('data-lng');
var this_index = $('.addresses-block a').index(this);
var mark_name = 'template_marker_'+this_index;
var mark_locat = new google.maps.LatLng(mark_lat, mark_lng);
var mark_str = $(this).attr('data-string');
addMarker(mark_locat,mark_name,mark_str);
});
}
$(window).load(function(){
setTimeout(function(){initialize();}, 500);
});
});