-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.js
More file actions
32 lines (25 loc) · 1.08 KB
/
map.js
File metadata and controls
32 lines (25 loc) · 1.08 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
function initialize() {
var mapOptions = {
zoom: 19,
center: new google.maps.LatLng(45.045179, -93.471339),
mapTypeId: google.maps.MapTypeId.SATELLITE
};
map = new google.maps.Map(document.getElementById('map'),
mapOptions);
new google.maps.Marker({map:map,position:map.getCenter()})
google.maps.event.addListener(map, 'center_changed', function() {
//a value to determine whether the map has been resized
var size=[this.getDiv().offsetWidth,this.getDiv().offsetHeight].join('x');
//when the center has changed, but not the size of the map
if(!this.get('size') || size===this.get('size')){
this.setValues({size:size,_center:this.getCenter()});
}
//when the map has been resized
else{
google.maps.event.addListenerOnce(this,'idle',function(){
this.setValues({size:size,center:this.get('_center')});});
}
});
//trigger the resize-event to initialize the size and _center-values
google.maps.event.trigger(map,'center_changed',{});
}