1 // JS helper functions for YM4R
\r
3 function addInfoWindowToMarker(marker,info,options){
\r
4 GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(info,options);});
\r
8 function addInfoWindowTabsToMarker(marker,info,options){
\r
9 GEvent.addListener(marker, "click", function() {marker.openInfoWindowTabsHtml(info,options);});
\r
13 function addPropertiesToLayer(layer,getTile,copyright,opacity,isPng){
\r
14 layer.getTileUrl = getTile;
\r
15 layer.getCopyright = copyright;
\r
16 layer.getOpacity = opacity;
\r
17 layer.isPng = isPng;
\r
21 function addOptionsToIcon(icon,options){
\r
22 for(var k in options){
\r
23 icon[k] = options[k];
\r
28 function addCodeToFunction(func,code){
\r
29 if(func == undefined)
\r
39 function addGeocodingToMarker(marker,address){
\r
40 marker.orig_initialize = marker.initialize;
\r
41 orig_redraw = marker.redraw;
\r
42 marker.redraw = function(force){}; //empty the redraw method so no error when called by addOverlay.
\r
43 marker.initialize = function(map){
\r
44 new GClientGeocoder().getLatLng(address,
\r
47 marker.redraw = orig_redraw;
\r
48 marker.orig_initialize(map); //init before setting point
\r
49 marker.setPoint(latlng);
\r
58 GMap2.prototype.centerAndZoomOnMarkers = function(markers) {
\r
59 var bounds = new GLatLngBounds(markers[0].getPoint(),
\r
60 markers[0].getPoint());
\r
61 for (var i=1, len = markers.length ; i<len; i++) {
\r
62 bounds.extend(markers[i].getPoint());
\r
65 this.centerAndZoomOnBounds(bounds);
\r
68 GMap2.prototype.centerAndZoomOnPoints = function(points) {
\r
69 var bounds = new GLatLngBounds(points[0],
\r
71 for (var i=1, len = points.length ; i<len; i++) {
\r
72 bounds.extend(points[i]);
\r
75 this.centerAndZoomOnBounds(bounds);
\r
78 GMap2.prototype.centerAndZoomOnBounds = function(bounds) {
\r
79 var center = bounds.getCenter();
\r
80 this.setCenter(center, this.getBoundsZoomLevel(bounds));
\r
83 //For full screen mode
\r
84 function setWindowDims(elem) {
\r
85 if (window.innerWidth){
\r
86 elem.style.height = (window.innerHeight) + 'px;';
\r
87 elem.style.width = (window.innerWidth) + 'px;';
\r
88 }else if (document.body.clientWidth){
\r
89 elem.style.width = (document.body.clientWidth) + 'px';
\r
90 elem.style.height = (document.body.clientHeight) + 'px';
\r
94 ManagedMarker = function(markers,minZoom,maxZoom) {
\r
95 this.markers = markers;
\r
96 this.minZoom = minZoom;
\r
97 this.maxZoom = maxZoom;
\r
100 //Add the markers and refresh
\r
101 function addMarkersToManager(manager,managedMarkers){
\r
102 for(var i = 0, length = managedMarkers.length; i < length;i++) {
\r
103 mm = managedMarkers[i];
\r
104 manager.addMarkers(mm.markers,mm.minZoom,mm.maxZoom);
\r
111 var INVISIBLE = new GLatLng(0,0); //almost always invisible
\r
113 if(self.Event && Event.observe){
\r
114 Event.observe(window, 'unload', GUnload);
\r
116 window.onunload = GUnload;
\r