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
145
146
147
148
149
150
151
152
153
154
155
156
|
/**
* Theme: Appzia Admin
* Google Maps
*/
!function($) {
"use strict";
var GoogleMap = function() {};
//creates map with markers
GoogleMap.prototype.createMarkers = function($container) {
var map = new GMaps({
div: $container,
lat: -12.043333,
lng: -77.028333
});
//sample markers, but you can pass actual marker data as function parameter
map.addMarker({
lat: -12.043333,
lng: -77.03,
title: 'Lima',
details: {
database_id: 42,
author: 'HPNeo'
},
click: function(e){
if(console.log)
console.log(e);
alert('You clicked in this marker');
}
});
map.addMarker({
lat: -12.042,
lng: -77.028333,
title: 'Marker with InfoWindow',
infoWindow: {
content: '<p>HTML Content</p>'
}
});
return map;
},
//creates map with overlay
GoogleMap.prototype.createWithOverlay = function ($container) {
var map = new GMaps({
div: $container,
lat: -12.043333,
lng: -77.028333
});
map.drawOverlay({
lat: map.getCenter().lat(),
lng: map.getCenter().lng(),
content: '<div class="gmaps-overlay">Our Office!<div class="gmaps-overlay_arrow above"></div></div>',
verticalAlign: 'top',
horizontalAlign: 'center'
});
return map;
},
//creates map with street view
GoogleMap.prototype.createWithStreetview = function ($container, $lat, $lng) {
return GMaps.createPanorama({
el: $container,
lat : $lat,
lng : $lng
});
},
//Type
GoogleMap.prototype.createMapByType = function ($container, $lat, $lng) {
var map = new GMaps({
div: $container,
lat: $lat,
lng: $lng,
mapTypeControlOptions: {
mapTypeIds : ["hybrid", "roadmap", "satellite", "terrain", "osm", "cloudmade"]
}
});
map.addMapType("osm", {
getTileUrl: function(coord, zoom) {
return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
},
tileSize: new google.maps.Size(256, 256),
name: "OpenStreetMap",
maxZoom: 18
});
map.addMapType("cloudmade", {
getTileUrl: function(coord, zoom) {
return "http://b.tile.cloudmade.com/8ee2a50541944fb9bcedded5165f09d9/1/256/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
},
tileSize: new google.maps.Size(256, 256),
name: "CloudMade",
maxZoom: 18
});
map.setMapTypeId("osm");
return map;
},
GoogleMap.prototype.createWithMenu = function ($container, $lat, $lng) {
var map = new GMaps({
div: $container,
lat: $lat,
lng: $lng
});
map.setContextMenu({
control: 'map',
options: [{
title: 'Add marker',
name: 'add_marker',
action: function(e){
this.addMarker({
lat: e.latLng.lat(),
lng: e.latLng.lng(),
title: 'New marker'
});
this.hideContextMenu();
}
}, {
title: 'Center here',
name: 'center_here',
action: function(e){
this.setCenter(e.latLng.lat(), e.latLng.lng());
}
}]
});
},
//init
GoogleMap.prototype.init = function() {
var $this = this;
$(document).on('ready', function(){
//with sample markers
$this.createMarkers('#gmaps-markers');
//overlay
$this.createWithOverlay('#gmaps-overlay');
//street view
$this.createWithStreetview('#panorama', 42.3455, -71.0983);
//types
$this.createMapByType('#gmaps-types', -12.043333, -77.028333);
});
},
//init
$.GoogleMap = new GoogleMap, $.GoogleMap.Constructor = GoogleMap
}(window.jQuery),
//initializing
function($) {
"use strict";
$.GoogleMap.init()
}(window.jQuery);
|