Index: trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.min.js |
— | — | @@ -1,12 +1,20 @@ |
2 | | -var GOverlays=[new GLayer("com.panoramio.all"),new GLayer("com.youtube.all"),new GLayer("org.wikipedia.en"),new GLayer("com.google.webcams")]; |
3 | | -function createGMarker(b,a,d,c){var e;if(c!=""){var f=new GIcon(G_DEFAULT_ICON);f.image=c;e=new GMarker(b,{icon:f})}else e=new GMarker(b);if((a+d).length>0){var g=(b=a.length>0&&d.length>0)?"<b>"+a+"</b><hr />"+d:a+d;g='<div style="overflow:auto;max-height:150px;">'+g+"</div>";GEvent.addListener(e,"click",function(){e.openInfoWindowHtml(g,{maxWidth:350})})}return e} |
4 | | -function initializeGoogleMap(b,a,d){if(GBrowserIsCompatible()){a.centre=a.lat!=null&&a.lon!=null?new GLatLng(a.lat,a.lon):null;a.size=new GSize(a.width,a.height);return createGoogleMap(b,a,d)}else return false} |
5 | | -function createGoogleMap(b,a,d){for(var c=document.getElementById(b),e=false,f=0;f<a.types.length;f++)if(a.types[f]==a.type)e=true;e||a.types.push(a.type);c=new GMap2(c,{size:a.size,mapTypes:a.types});c.name=b;c.setMapType(a.type);for(f in a.controls){if(a.controls[f].toLowerCase()=="auto")if(a.height>75)a.controls[f]=a.height>320?"large":"small";switch(a.controls[f]){case "large":c.addControl(new GLargeMapControl3D);break;case "small":c.addControl(new GSmallZoomControl3D);break;case "large-original":c.addControl(new GLargeMapControl); |
6 | | -break;case "small-original":c.addControl(new GSmallMapControl);break;case "zoom":c.addControl(new GSmallZoomControl);break;case "type":c.addControl(new GMapTypeControl);break;case "type-menu":c.addControl(new GMenuMapTypeControl);break;case "overlays":c.addControl(new MoreControl);break;case "overview":case "overview-map":c.addControl(new GOverviewMapControl);break;case "scale":c.addControl(new GScaleControl);break;case "nav-label":case "nav":c.addControl(new GNavLabelControl);break}}e=(a.zoom==null|| |
7 | | -a.centre==null)&&d.length>1?new GLatLngBounds:null;for(f in d){var g=d[f];c.addOverlay(createGMarker(g.point,g.title,g.label,g.icon));e!=null&&e.extend(g.point)}e!=null&&c.setCenter(e.getCenter(),c.getBoundsZoomLevel(e));a.centre!=null&&c.setCenter(a.centre);a.zoom!=null&&c.setZoom(a.zoom);a.scrollWheelZoom&&c.enableScrollWheelZoom();c.enableContinuousZoom();if(!window.GMaps)window.GMaps={};eval("window.GMaps."+b+" = map;");return c} |
8 | | -function getGMarkerData(b,a,d,c,e){return{point:new GLatLng(b,a),title:d,label:c,icon:e}}function setupCheckboxShiftClick(){return true}function MoreControl(){}MoreControl.prototype=new GControl; |
9 | | -MoreControl.prototype.initialize=function(b){this.map=b;var a=document.getElementById(b.name+"-outer-more"),d=document.createElement("div");d.id=b.name+"-more-button";d.title="Show/Hide Overlays";d.style.border="1px solid black";d.style.width="86px";var c=document.createElement("div");c.id=b.name+"-inner-more";c.setAttribute("class","inner-more");c.appendChild(document.createTextNode("Overlays"));d.appendChild(c);a.onmouseover=showGLayerbox;a.onmouseout=setGLayerboxClose;a.insertBefore(d,document.getElementById(b.name+ |
10 | | -"-more-box").parentNode);b.getContainer().appendChild(a);return a};MoreControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,35))};function checkGChecked(b){b=document.getElementsByName(b+"-overlay-box");for(var a=0;a<b.length;a++)if(b[a].checked)return true;return false} |
11 | | -function showGLayerbox(){var b=this.id.split("-")[0];eval("if(window.timer_"+b+") clearTimeout(timer_"+b+");");document.getElementById(b+"-more-box").style.display="block";b=document.getElementById(b+"-inner-more");b.style.borderBottomWidth="4px";b.style.borderBottomColor="white"} |
12 | | -function setGLayerboxClose(){var b=this.id.split("-")[0],a=document.getElementById(b+"-more-box");a=document.getElementById(b+"-inner-more");a=checkGChecked(b)?"#6495ed":"#c0c0c0";eval("timer_"+b+" = window.setTimeout(function() { layerbox.style.display = 'none'; button.style.borderBottomWidth = '1px'; button.style.borderBottomColor = bottomColor; }, 400);")} |
13 | | -function switchGLayer(b,a,d){var c=document.getElementById(b.name+"-more-box");c=document.getElementById(b.name+"-inner-more");a?b.addOverlay(d):b.removeOverlay(d)}function initiateGOverlay(b,a,d){document.getElementById(b).checked=true;switchGLayer(GMaps[a],true,GOverlays[d])}; |
\ No newline at end of file |
| 2 | +var GOverlays=[new GLayer("com.panoramio.all"),new GLayer("com.youtube.all"),new GLayer("org.wikipedia.en"),new GLayer("com.google.webcams")];function createGMarker(point,title,label,icon){var marker;if(icon!=''){var iconObj=new GIcon(G_DEFAULT_ICON);iconObj.image=icon;marker=new GMarker(point,{icon:iconObj});}else{marker=new GMarker(point);} |
| 3 | +if((title+label).length>0){var bothTxtAreSet=title.length>0&&label.length>0;var popupText=bothTxtAreSet?'<b>'+title+'</b><hr />'+label:title+label;popupText='<div style="overflow:auto;max-height:150px;">'+popupText+'</div>';GEvent.addListener(marker,'click',function(){marker.openInfoWindowHtml(popupText,{maxWidth:350});});} |
| 4 | +return marker;} |
| 5 | +function initializeGoogleMap(mapName,mapOptions,markers){if(GBrowserIsCompatible()){mapOptions.centre=(mapOptions.lat!=null&&mapOptions.lon!=null)?new GLatLng(mapOptions.lat,mapOptions.lon):null;mapOptions.size=new GSize(mapOptions.width,mapOptions.height);return createGoogleMap(mapName,mapOptions,markers);} |
| 6 | +else{return false;}} |
| 7 | +function createGoogleMap(mapName,mapOptions,markers){var mapElement=document.getElementById(mapName);var typesContainType=false;for(var i=0;i<mapOptions.types.length;i++){if(mapOptions.types[i]==mapOptions.type)typesContainType=true;} |
| 8 | +if(!typesContainType)mapOptions.types.push(mapOptions.type);var map=new GMap2(mapElement,{size:mapOptions.size,mapTypes:mapOptions.types});map.name=mapName;map.setMapType(mapOptions.type);for(i in mapOptions.controls){if(mapOptions.controls[i].toLowerCase()=='auto'){if(mapOptions.height>75)mapOptions.controls[i]=mapOptions.height>320?'large':'small';} |
| 9 | +switch(mapOptions.controls[i]){case'large':map.addControl(new GLargeMapControl3D());break;case'small':map.addControl(new GSmallZoomControl3D());break;case'large-original':map.addControl(new GLargeMapControl());break;case'small-original':map.addControl(new GSmallMapControl());break;case'zoom':map.addControl(new GSmallZoomControl());break;case'type':map.addControl(new GMapTypeControl());break;case'type-menu':map.addControl(new GMenuMapTypeControl());break;case'overlays':map.addControl(new MoreControl());break;case'overview':case'overview-map':map.addControl(new GOverviewMapControl());break;case'scale':map.addControl(new GScaleControl());break;case'nav-label':case'nav':map.addControl(new GNavLabelControl());break;}} |
| 10 | +var bounds=((mapOptions.zoom==null||mapOptions.centre==null)&&markers.length>1)?new GLatLngBounds():null;for(i in markers){var marker=markers[i];map.addOverlay(createGMarker(marker.point,marker.title,marker.label,marker.icon));if(bounds!=null)bounds.extend(marker.point);} |
| 11 | +if(bounds!=null){map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds));} |
| 12 | +if(mapOptions.centre!=null)map.setCenter(mapOptions.centre);if(mapOptions.zoom!=null)map.setZoom(mapOptions.zoom);if(mapOptions.scrollWheelZoom)map.enableScrollWheelZoom();map.enableContinuousZoom();if(!window.GMaps)window.GMaps=new Object;eval("window.GMaps."+mapName+" = map;");return map;} |
| 13 | +function getGMarkerData(lat,lon,title,label,icon){return{point:new GLatLng(lat,lon),title:title,label:label,icon:icon};} |
| 14 | +function setupCheckboxShiftClick(){return true;} |
| 15 | +function MoreControl(){};MoreControl.prototype=new GControl();MoreControl.prototype.initialize=function(map){this.map=map;var more=document.getElementById(map.name+"-outer-more");var buttonDiv=document.createElement("div");buttonDiv.id=map.name+"-more-button";buttonDiv.title="Show/Hide Overlays";buttonDiv.style.border="1px solid black";buttonDiv.style.width="86px";var textDiv=document.createElement("div");textDiv.id=map.name+"-inner-more";textDiv.setAttribute('class','inner-more');textDiv.appendChild(document.createTextNode("Overlays"));buttonDiv.appendChild(textDiv);more.onmouseover=showGLayerbox;more.onmouseout=setGLayerboxClose;more.insertBefore(buttonDiv,document.getElementById(map.name+"-more-box").parentNode);map.getContainer().appendChild(more);return more;};MoreControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,35));};function checkGChecked(mapName){var boxes=document.getElementsByName(mapName+"-overlay-box");for(var i=0;i<boxes.length;i++){if(boxes[i].checked)return true;} |
| 16 | +return false;} |
| 17 | +function showGLayerbox(){var mapName=this.id.split('-')[0];eval("if(window.timer_"+mapName+") clearTimeout(timer_"+mapName+");");document.getElementById(mapName+"-more-box").style.display="block";var button=document.getElementById(mapName+"-inner-more");button.style.borderBottomWidth="4px";button.style.borderBottomColor="white";} |
| 18 | +function setGLayerboxClose(){var mapName=this.id.split('-')[0];var layerbox=document.getElementById(mapName+"-more-box");var button=document.getElementById(mapName+"-inner-more");var bottomColor=checkGChecked(mapName)?"#6495ed":"#c0c0c0";eval("timer_"+mapName+" = window.setTimeout(function() { layerbox.style.display = 'none'; button.style.borderBottomWidth = '1px'; button.style.borderBottomColor = bottomColor; }, 400);");} |
| 19 | +function switchGLayer(map,checked,layer){var layerbox=document.getElementById(map.name+"-more-box");var button=document.getElementById(map.name+"-inner-more");if(checked){map.addOverlay(layer);} |
| 20 | +else{map.removeOverlay(layer);}} |
| 21 | +function initiateGOverlay(elementId,mapName,urlNr){document.getElementById(elementId).checked=true;switchGLayer(GMaps[mapName],true,GOverlays[urlNr]);} |
\ No newline at end of file |