1
|
|
|
;(function( window, document, undefined ) { |
|
|
|
|
2
|
|
|
"use strict"; |
3
|
|
|
|
4
|
|
|
var Plugin = function( selector, options, markerOptions ) |
5
|
|
|
{ |
6
|
|
|
this.el = castor._isString( selector ) ? document.querySelector( selector ) : selector; |
|
|
|
|
7
|
|
|
if( this.el ) { |
8
|
|
|
this.options = castor._extend( this.defaults, options, this.el.getAttribute( 'data-map-options' )); |
9
|
|
|
this.init( markerOptions ); |
10
|
|
|
} |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
Plugin.prototype = |
14
|
|
|
{ |
15
|
|
|
defaults: { |
16
|
|
|
center: { lat:0, lng:0 }, |
17
|
|
|
disableDoubleClickZoom: true, |
18
|
|
|
draggable: true, |
19
|
|
|
fullscreenControl: false, |
20
|
|
|
mapTypeControl: false, |
21
|
|
|
// mapTypeId: google.maps.MapTypeId.ROADMAP, |
22
|
|
|
overviewMapControl: false, |
23
|
|
|
rotateControl: false, |
24
|
|
|
scaleControl: false, |
25
|
|
|
scrollwheel: false, |
26
|
|
|
streetViewControl: false, |
27
|
|
|
styles: [], |
28
|
|
|
zoom: 16, |
29
|
|
|
zoomControl: true, |
30
|
|
|
}, |
31
|
|
|
|
32
|
|
|
init: function( markerOptions ) |
33
|
|
|
{ |
34
|
|
|
this.map = new google.maps.Map( this.el, this.options ); |
|
|
|
|
35
|
|
|
|
36
|
|
|
this.markerOptions = castor._extend({ |
|
|
|
|
37
|
|
|
position: this.options.center, |
38
|
|
|
animation: google.maps.Animation.DROP, |
39
|
|
|
}, markerOptions, this.el.getAttribute( 'data-marker-options' ), { map: this.map }); |
40
|
|
|
|
41
|
|
|
this.marker = new google.maps.Marker( this.markerOptions ); |
42
|
|
|
|
43
|
|
|
google.maps.event.addDomListener( window, 'resize', this.onResize.bind( this )); |
44
|
|
|
}, |
45
|
|
|
|
46
|
|
|
onResize: function() |
47
|
|
|
{ |
48
|
|
|
(new AnimationFrame()).request( function() { |
|
|
|
|
49
|
|
|
this.map.setCenter( this.marker.getPosition() ); |
50
|
|
|
}.bind( this )); |
51
|
|
|
}, |
52
|
|
|
}; |
53
|
|
|
|
54
|
|
|
Plugin.defaults = Plugin.prototype.defaults; |
55
|
|
|
|
56
|
|
|
castor.GoogleMaps = Plugin; |
|
|
|
|
57
|
|
|
|
58
|
|
|
})( window, document ); |
59
|
|
|
|
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.