-
Notifications
You must be signed in to change notification settings - Fork 0
/
map-custom.js
77 lines (62 loc) · 2.57 KB
/
map-custom.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
(function ($) {
// USE STRICT
"use strict";
$(document).ready(function () {
var selector_map = $('#google_map');
var img_pin = selector_map.attr('data-pin');
var data_map_x = selector_map.attr('data-map-x');
var data_map_y = selector_map.attr('data-map-y');
var scrollwhell = selector_map.attr('data-scrollwhell');
var draggable = selector_map.attr('data-draggable');
if (img_pin == null) {
img_pin = 'images/icons/location.png';
}
if (data_map_x == null || data_map_y == null) {
data_map_x = 21.031428;
data_map_y = 105.779817;
}
if (scrollwhell == null) {
scrollwhell = 0;
}
if (draggable == null) {
draggable = 0;
}
var style = [];
var latitude = data_map_x,
longitude = data_map_y,
map_zoom = 14;
var locations = [
['<div class="infobox"><p>Now that you visited our website, how' +
' <br>about checking out our office too?</p></div>'
, latitude, longitude, 2]
];
if (selector_map !== undefined) {
var map = new google.maps.Map(document.getElementById('google_map'), {
zoom: 15,
scrollwheel: scrollwhell,
navigationControl: true,
mapTypeControl: false,
scaleControl: false,
draggable: draggable,
styles: style,
center: new google.maps.LatLng(latitude, longitude),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
}
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon: img_pin
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
});
})(jQuery);