[Commits] r870 - in apps/opengeo/geoexplorer/trunk: build lib/GeoExplorer/Full script
commits at geoext.org
commits at geoext.org
Wed May 27 21:23:15 CEST 2009
Author: dwins
Date: 2009-05-27 21:23:15 +0200 (Wed, 27 May 2009)
New Revision: 870
Modified:
apps/opengeo/geoexplorer/trunk/build/geoexplorer-all.cfg
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/Full/Full.js
apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js
apps/opengeo/geoexplorer/trunk/script/GeoExplorer.js
Log:
Add a Wizard class to use for the export wizard, start out with just the 'Finish' pane.
Modified: apps/opengeo/geoexplorer/trunk/build/geoexplorer-all.cfg
===================================================================
--- apps/opengeo/geoexplorer/trunk/build/geoexplorer-all.cfg 2009-05-27 19:22:28 UTC (rev 869)
+++ apps/opengeo/geoexplorer/trunk/build/geoexplorer-all.cfg 2009-05-27 19:23:15 UTC (rev 870)
@@ -77,5 +77,5 @@
GeoExplorer.js
GeoExplorer/Full/Full.js
GeoExplorer/Embed/Embed.js
-
+ GeoExplorer/Wizard.js
Modified: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/Full/Full.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/Full/Full.js 2009-05-27 19:22:28 UTC (rev 869)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/Full/Full.js 2009-05-27 19:23:15 UTC (rev 870)
@@ -20,9 +20,107 @@
scope: this,
iconCls: "icon-save"
}));
+ tools.unshift(new Ext.Button({
+ tooltip: "Export as blog widget",
+ text: 'Export',
+ handler: this.showEmbedWizard,
+ scope: this,
+ iconCls: 'icon-save'
+ }));
tools.unshift("-");
tools.unshift(aboutButton);
return tools;
+ },
+
+ showEmbedWizard: function() {
+ var config = this.extractConfiguration();
+
+ var finalize = this.makeFinalWizardPane(config);
+ var wizard = new GeoExplorer.Wizard({
+ height: 300,
+ width: 400,
+ resizable: false,
+ modal: true,
+ title: "Export Map",
+ pages: [{title: 'Finish', panel: finalize}]
+ });
+ wizard.show();
+ },
+
+ makeFinalWizardPane: function(config) {
+ var description = new Ext.Panel({
+ html: '<p> Your map is ready to be published to the web! </p>' +
+ '<p> Simply copy the following HTML to embed the map in your website: </p>',
+ border: false
+ });
+
+ var snippetArea = new Ext.form.TextArea({
+ editable: false,
+ height: 'auto'
+ });
+
+ var heightField = new Ext.form.NumberField({width: 50, value: 400});
+ var widthField = new Ext.form.NumberField({width: 50, value: 600});
+
+ var updateSnippet = function() {
+ snippetArea.setValue('<iframe height="' + heightField.getValue() +
+ ' " width="' + widthField.getValue() + '" src="' +
+ Ext.urlEncode(config) +
+ '"> </iframe>');
+ };
+
+ heightField.on("change", updateSnippet);
+ widthField.on("change", updateSnippet);
+
+ updateSnippet();
+
+ var snippet = new Ext.Panel({
+ border: false,
+ layout: 'fit',
+ items: [snippetArea]
+ });
+
+ var adjustments = new Ext.Panel({
+ layout: "column",
+ items: [
+ new Ext.Panel({
+ border: false,
+ width: 90,
+ items: [
+ new Ext.form.ComboBox({
+ editable: false,
+ width: 70,
+ store: new Ext.data.SimpleStore({
+ fields: ["name", "height", "width"],
+ data: [
+ ["Mini", 100, 100],
+ ["Small", 200, 300],
+ ["Large", 400, 600],
+ ["Premium", 600, 800]
+ ]}),
+ triggerAction: 'all',
+ displayField: 'name',
+ value: "Large",
+ mode: 'local',
+ listeners: {
+ 'select': function(combo, record, index) {
+ widthField.setValue(record.get("width"));
+ heightField.setValue(record.get("height"));
+ updateSnippet();
+ }
+ }
+ })
+ ]}),
+ {html: "Height", border: false},
+ heightField,
+ {html: "Width", border: false},
+ widthField
+ ],
+ border: false
+ });
+
+ return new Ext.Panel({
+ items: [description, snippet, {html: "Map Size", border: false}, adjustments]
+ });
}
-
});
Modified: apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js 2009-05-27 19:22:28 UTC (rev 869)
+++ apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js 2009-05-27 19:23:15 UTC (rev 870)
@@ -9,6 +9,7 @@
"lib/GeoExplorer/MapToolToggle.js",
"lib/GeoExplorer/MapToolSplitToggle.js",
"lib/GeoExplorer/MapToolMenu.js",
+ "lib/GeoExplorer/Wizard.js",
"lib/GeoExplorer/LayerMenuItem.js",
"lib/GeoExplorer/CapabilitiesGrid.js",
"lib/GeoExplorer/Full/Full.js",
Modified: apps/opengeo/geoexplorer/trunk/script/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/script/GeoExplorer.js 2009-05-27 19:22:28 UTC (rev 869)
+++ apps/opengeo/geoexplorer/trunk/script/GeoExplorer.js 2009-05-27 19:23:15 UTC (rev 870)
@@ -1164,14 +1164,14 @@
this.layers.add(records);if(this.mapPanel.center){this.map.setCenter(this.mapPanel.center,this.mapPanel.zoom);}else if(this.mapPanel.extent){this.map.zoomToExtent(this.mapPanel.extent);}else{this.map.zoomToMaxExtent();}}},initCapGrid:function(){var capGridPanel=new CapabilitiesGrid({store:this.capabilities,mapPanel:this.mapPanel,layout:'fit',region:'center',autoScroll:true,alignToGrid:this.alignToGrid,listeners:{rowdblclick:function(panel,index,evt){panel.addLayers();}}});this.capGrid=new Ext.Window({title:"Available Layers",closeAction:'hide',layout:'border',height:300,width:600,items:[capGridPanel],bbar:["->",new Ext.Button({text:"Add Layers",iconCls:"icon-addlayers",handler:function(){capGridPanel.addLayers();},scope:this}),new Ext.Button({text:"Done",handler:function(){this.capGrid.hide();},scope:this})],listeners:{hide:function(win){capGridPanel.getSelectionModel().clearSelections();}}});},showCapabilitiesGrid:function(){if(!this.capGrid){this.initCapGrid();}
this.capGrid.show();},createMapOverlay:function(){var scaleLinePanel=new Ext.Panel({cls:'olControlScaleLine overlay-element overlay-scaleline',border:false});scaleLinePanel.on('render',function(){var scaleLine=new OpenLayers.Control.ScaleLine({div:scaleLinePanel.body.dom});this.map.addControl(scaleLine);scaleLine.activate();},this);var zoomStore=new GeoExt.data.ScaleStore({map:this.map});var zoomSelector=new Ext.form.ComboBox({emptyText:'Zoom level',tpl:'<tpl for="."><div class="x-combo-list-item">1 : {[parseInt(values.scale)]}</div></tpl>',editable:false,triggerAction:'all',mode:'local',store:zoomStore,width:110});zoomSelector.on('click',function(evt){evt.stopEvent();});zoomSelector.on('mousedown',function(evt){evt.stopEvent();});zoomSelector.on('select',function(combo,record,index){this.map.zoomTo(record.data.level);},this);var zoomSelectorWrapper=new Ext.Panel({items:[zoomSelector],cls:'overlay-element overlay-scalechooser',border:false});this.map.events.register('zoomend',this,function(){var scale=zoomStore.queryBy(function(record){return this.map.getZoom()==record.data.level;});if(scale.length>0){scale=scale.items[0];zoomSelector.setValue("1 : "+parseInt(scale.data.scale,10));}else{if(!zoomSelector.rendered)return;zoomSelector.clearValue();}});var mapOverlay=new Ext.Panel({cls:'map-overlay',items:[scaleLinePanel,zoomSelectorWrapper]});mapOverlay.on("afterlayout",function(){scaleLinePanel.body.dom.style.position='relative';scaleLinePanel.body.dom.style.display='inline';mapOverlay.getEl().on("click",function(x){x.stopEvent();});mapOverlay.getEl().on("mousedown",function(x){x.stopEvent();});},this);return mapOverlay;},createTools:function(){var navControl=new OpenLayers.Control.Navigation();this.map.addControl(navControl);var historyControl=new OpenLayers.Control.NavigationHistory();var navPreviousButton=new Ext.Button({tooltip:"Zoom to Previous Extent",iconCls:"icon-zoom-previous",disabled:true,handler:function(){historyControl.previous.trigger();}});historyControl.previous.events.on({activate:function(){navPreviousButton.enable();},deactivate:function(){navPreviousButton.disable();}});var navNextButton=new Ext.Button({tooltip:"Zoom to Next Extent",iconCls:"icon-zoom-next",disabled:true,handler:function(){historyControl.next.trigger();}});historyControl.next.events.on({activate:function(){navNextButton.enable();},deactivate:function(){navNextButton.disable();}});this.map.addControl(historyControl);var toolGroup="toolGroup";var info={controls:[]};var infoButton=new Ext.Button({tooltip:"Get Feature Info",iconCls:"icon-getfeatureinfo",toggleGroup:toolGroup,enableToggle:true,allowDepress:false,toggleHandler:function(button,pressed){for(var i=0,len=info.controls.length;i<len;i++){if(pressed){info.controls[i].activate();}else{info.controls[i].deactivate();}}}})
var updateInfo=function(){var queryableLayers=this.mapPanel.layers.queryBy(function(x){return x.get("queryable");});var map=this.mapPanel.map;var gx=this;for(var i=0,len=info.controls.length;i<len;i++){map.removeControl(info.controls[i]);}
-info.controls=[];queryableLayers.each(function(x){var control=new OpenLayers.Control.WMSGetFeatureInfo({url:x.get("layer").url,queryVisible:true,layers:[x.get("layer")],eventListeners:{getfeatureinfo:function(evt){gx.displayPopup(evt,x.get("title"));},scope:gx}});map.addControl(control);info.controls.push(control);});};this.mapPanel.layers.on("update",updateInfo,this);this.mapPanel.layers.on("add",updateInfo,this);this.mapPanel.layers.on("remove",updateInfo,this);var measureLength=this.createMeasureTool(OpenLayers.Handler.Path,'Length');this.map.addControl(measureLength);var measureArea=this.createMeasureTool(OpenLayers.Handler.Polygon,'Area');this.map.addControl(measureArea);var tools=[new Ext.Button({tooltip:"Bookmark",handler:this.bookmark,scope:this,iconCls:"icon-save"}),"-",new Ext.Button({tooltip:"Pan Map",iconCls:"icon-pan",enableToggle:true,pressed:true,allowDepress:false,toggleGroup:toolGroup,toggleHandler:function(b,pressed){if(pressed){navControl.activate();}else{navControl.deactivate();}},scope:this}),infoButton,new MapToolSplitToggle({tooltip:"Measure",iconCls:"icon-measure-length",defaultTool:measureLength,allowDepress:false,tools:[{text:'Length',tool:measureLength,iconCls:'icon-measure-length'},{text:'Area',tool:measureArea,iconCls:'icon-measure-area'}],enableToggle:true,toggleGroup:toolGroup}),"-",new Ext.Button({handler:function(){this.map.zoomIn();},tooltip:"Zoom In",iconCls:"icon-zoom-in",scope:this}),new Ext.Button({tooltip:"Zoom Out",handler:function(){this.map.zoomOut();},iconCls:"icon-zoom-out",scope:this}),navPreviousButton,navNextButton,new Ext.Button({tooltip:"Zoom to Visible Extent",iconCls:"icon-zoom-visible",handler:function(){var extent,layer;for(var i=0,len=this.map.layers.length;i<len;++i){layer=this.map.layers[i];if(layer.getVisibility()){if(extent){extent.extend(layer.maxExtent);}else{extent=layer.maxExtent.clone();}}}
+info.controls=[];queryableLayers.each(function(x){var control=new OpenLayers.Control.WMSGetFeatureInfo({url:x.get("layer").url,queryVisible:true,layers:[x.get("layer")],eventListeners:{getfeatureinfo:function(evt){gx.displayPopup(evt,x.get("title"));},scope:gx}});map.addControl(control);info.controls.push(control);});};this.mapPanel.layers.on("update",updateInfo,this);this.mapPanel.layers.on("add",updateInfo,this);this.mapPanel.layers.on("remove",updateInfo,this);var measureLength=this.createMeasureTool(OpenLayers.Handler.Path,'Length');this.map.addControl(measureLength);var measureArea=this.createMeasureTool(OpenLayers.Handler.Polygon,'Area');this.map.addControl(measureArea);var tools=[new Ext.Button({tooltip:"Pan Map",iconCls:"icon-pan",enableToggle:true,pressed:true,allowDepress:false,toggleGroup:toolGroup,toggleHandler:function(b,pressed){if(pressed){navControl.activate();}else{navControl.deactivate();}},scope:this}),infoButton,new MapToolSplitToggle({tooltip:"Measure",iconCls:"icon-measure-length",defaultTool:measureLength,allowDepress:false,tools:[{text:'Length',tool:measureLength,iconCls:'icon-measure-length'},{text:'Area',tool:measureArea,iconCls:'icon-measure-area'}],enableToggle:true,toggleGroup:toolGroup}),"-",new Ext.Button({handler:function(){this.map.zoomIn();},tooltip:"Zoom In",iconCls:"icon-zoom-in",scope:this}),new Ext.Button({tooltip:"Zoom Out",handler:function(){this.map.zoomOut();},iconCls:"icon-zoom-out",scope:this}),navPreviousButton,navNextButton,new Ext.Button({tooltip:"Zoom to Visible Extent",iconCls:"icon-zoom-visible",handler:function(){var extent,layer;for(var i=0,len=this.map.layers.length;i<len;++i){layer=this.map.layers[i];if(layer.getVisibility()){if(extent){extent.extend(layer.maxExtent);}else{extent=layer.maxExtent.clone();}}}
if(extent){this.map.zoomToExtent(extent);}},scope:this})];return tools;},createMeasureTool:function(handlerType,title){var styleMap=new OpenLayers.StyleMap({"default":new OpenLayers.Style(null,{rules:[new OpenLayers.Rule({symbolizer:{"Point":{pointRadius:4,graphicName:"square",fillColor:"white",fillOpacity:1,strokeWidth:1,strokeOpacity:1,strokeColor:"#333333"},"Line":{strokeWidth:3,strokeOpacity:1,strokeColor:"#666666",strokeDashstyle:"dash"},"Polygon":{strokeWidth:2,strokeOpacity:1,strokeColor:"#666666",fillColor:"white",fillOpacity:0.3}}})]})});var cleanup=function(){if(measureToolTip){measureToolTip.destroy();}};var makeString=function(metricData){var metric=metricData.measure;var metricUnit=metricData.units;measureControl.displaySystem="english";var englishData=metricData.geometry.CLASS_NAME.indexOf("LineString")>-1?measureControl.getBestLength(metricData.geometry):measureControl.getBestArea(metricData.geometry);var english=englishData[0];var englishUnit=englishData[1];measureControl.displaySystem="metric";var dim=metricData.order==2?'<sup>2</sup>':'';return metric.toFixed(2)+" "+metricUnit+dim+"<br>"+
english.toFixed(2)+" "+englishUnit+dim;};var measureToolTip;var measureControl=new OpenLayers.Control.Measure(handlerType,{persist:true,handlerOptions:{layerOptions:{styleMap:styleMap}},eventListeners:{measurepartial:function(event){cleanup();measureToolTip=new Ext.ToolTip({target:Ext.getBody(),html:makeString(event),title:title,autoHide:false,closable:true,draggable:false,mouseOffset:[0,0],showDelay:1,listeners:{hide:cleanup}});if(event.measure>0){var px=measureControl.handler.lastUp;var p0=this.mapPanel.getPosition();measureToolTip.targetXY=[p0[0]+px.x,p0[1]+px.y];measureToolTip.show();}},measure:function(event){cleanup();measureToolTip=new Ext.ToolTip({target:Ext.getBody(),html:makeString(event),title:title,autoHide:false,closable:true,draggable:false,mouseOffset:[0,0],showDelay:1,listeners:{hide:function(){measureControl.cancel();cleanup();}}});},deactivate:cleanup,scope:this}});return measureControl;},displayPopup:function(evt,title){var popup;var popupKey=evt.xy.x+"."+evt.xy.y;if(!(popupKey in this.popupCache)){var lonlat=this.map.getLonLatFromPixel(evt.xy);popup=new GeoExt.Popup({title:"Feature Info",lonlat:lonlat,width:250,height:300,autoScroll:true,listeners:{close:(function(key){return function(panel){delete this.popupCache[key];};})(popupKey),scope:this}});popup.addToMapPanel(this.mapPanel);popup.show();this.popupCache[popupKey]=popup;}else{popup=this.popupCache[popupKey];}
var html=evt.text;if(!(html==''||html.match(/<body>\s*<\/body>/))){popup.add({title:title,html:html,autoScroll:true,collapsible:true});}
popup.doLayout();},bookmark:function(){var config=this.extractConfiguration();var query=Ext.urlEncode({q:Ext.util.JSON.encode(config)});var url=document.location.protocol+"//"+
document.location.hostname+
-document.location.pathname+"?"+query;var win=new Ext.Window({title:"Bookmark URL",layout:'form',items:[{xtype:'textfield',fieldLabel:'Permalink',readOnly:true,value:url}],width:300});win.show();return url;},extractConfiguration:function(){var config={};var center=this.map.getCenter();config.map={center:[center.lon,center.lat],zoom:this.map.zoom};config.map.layers=[];this.layers.each(function(layerRecord){var c={title:layerRecord.get("title"),name:(layerRecord.get("layer").params&&layerRecord.get("layer").params.LAYERS)||layerRecord.get("name"),visibility:layerRecord.get("layer").getVisibility()};config.map.layers.push(c);});return config;},displayAppInfo:function(){var win=new Ext.Window({title:"About GeoExplorer",html:"<iframe style=\"border: none; height: 100%; width: 100%\" src=\"about.html\"><a target=\"_blank\" href=\"about.html\">About GeoExplorer</a> </iframe>",modal:true,width:300,height:350});win.show();}});GeoExplorer.Full=Ext.extend(GeoExplorer,{createTools:function(){var tools=GeoExplorer.Full.superclass.createTools.apply(this,arguments);var aboutButton=new Ext.Button({text:"GeoExplorer",iconCls:"icon-geoexplorer",handler:this.displayAppInfo});tools.unshift("-");tools.unshift(aboutButton);return tools;}});Ext.namespace("GeoExplorer");GeoExplorer.Embed=Ext.extend(GeoExplorer,{createLayout:function(){this.map=new OpenLayers.Map({allOverlays:true,controls:[new OpenLayers.Control.PanPanel(),new OpenLayers.Control.ZoomPanel()]});var onDoubleClick=function(ctrl,evt){OpenLayers.Event.stop(evt?evt:window.event);};var controls=this.map.controls[0].controls;for(var i=0;i<controls.length;i++){OpenLayers.Event.observe(controls[i].panel_div,"dblclick",OpenLayers.Function.bind(onDoubleClick,this.map.controls[0],controls[i]));}
-this.map.events.on({"preaddlayer":function(evt){if(evt.layer.mergeNewParams){var maxExtent=evt.layer.maxExtent;evt.layer.mergeNewParams({transparent:true,format:"image/png",tiled:true,tilesorigin:[maxExtent.left,maxExtent.bottom]});}},scope:this});var mapConfig=this.initialConfig.map||{};this.mapPanel=new GeoExt.MapPanel({layout:"anchor",border:true,region:"center",map:this.map,center:mapConfig.center&&new OpenLayers.LonLat(mapConfig.center[0],mapConfig.center[1]),zoom:mapConfig.zoom,items:[{xtype:"gx_scaleslider",vertical:true,height:100,plugins:new GeoExt.ScaleSliderTip({template:"<div>Zoom Level: {zoom}</div>"})},this.createMapOverlay()]});this.layers=this.mapPanel.layers;var addLayerButton=new Ext.Button({tooltip:"Add Layers",disabled:true,iconCls:"icon-addlayers",handler:this.showCapabilitiesGrid,scope:this});this.on("ready",function(){addLayerButton.enable();});var toolbar=new Ext.Toolbar({xtype:"toolbar",region:"north",disabled:true,items:this.createTools()});this.on("ready",function(){toolbar.enable();});var viewport=new Ext.Viewport({layout:"fit",hideBorders:true,items:{layout:"border",deferredRender:false,items:[toolbar,this.mapPanel]}});},createTools:function(){var tools=GeoExplorer.Embed.superclass.createTools.apply(this,arguments);var menu=new Ext.menu.Menu();var updateLayerSwitcher=function(){menu.removeAll();menu.addItem(new Ext.menu.TextItem({text:'<h3> <img height="24" width="48" src="http://www.google.com/logos/us_doodle4google09.gif"></img> Layers </h3>'}));this.mapPanel.layers.each(function(x){if(x.get("layer").displayInLayerSwitcher){menu.addItem(new GeoExplorer.LayerMenuItem({layerRecord:x}));}});}
-this.mapPanel.layers.on("update",updateLayerSwitcher,this);this.mapPanel.layers.on("remove",updateLayerSwitcher,this);this.mapPanel.layers.on("add",updateLayerSwitcher,this);var layerChooser=new Ext.Button({tooltip:'Layer Switcher',iconCls:'icon-layer-switcher',menu:menu});tools.unshift(layerChooser);return tools;}});GeoExplorer.LayerMenuItem=function(config){config.layout=config.layout||'column';Ext.menu.DateItem.superclass.constructor.call(this,new Ext.Panel(config),config);this.panel=this.component;var layerRecord=config.layerRecord;var queryRadio=null;if(layerRecord.get("queryable")){queryRadio=new Ext.form.Radio({checked:false,name:'query'});}else{queryRadio=new Ext.Panel();}
-var visibilityField=null;if(layerRecord.get("layer").isBaseLayer){visibilityField=new Ext.form.Radio({checked:layerRecord.get("layer").getVisibility(),handler:function(radio,checked){layerRecord.get('layer').setVisibility(checked);}});}else{visibilityField=new Ext.form.Checkbox({checked:layerRecord.get("layer").getVisibility(),handler:function(checkbox,checked){layerRecord.get("layer").setVisibility(checked);}});}
-this.panel.add(visibilityField);this.panel.add(queryRadio);this.panel.add({html:'<b>'+layerRecord.get("title")+'</b>',border:false});this.panel.on("render",function(panel){panel.getEl().swallowEvent("click");});};Ext.extend(GeoExplorer.LayerMenuItem,Ext.menu.Adapter);var MapToolToggle=function(options){this.mapTool=options.tool;Ext.applyIf(options,{text:this.findLabel(),enableToggle:true,iconCls:this.findIconCls(),handler:this.handleEvent,scope:this});MapToolToggle.superclass.constructor.call(this,options);};Ext.extend(MapToolToggle,Ext.Button,{mapTool:null,handleEvent:function(item){if(item.pressed){this.mapTool.activate();}else{this.mapTool.deactivate();}},findIconCls:function(){return this.mapTool.CLASS_NAME;},findLabel:function(){return this.mapTool.CLASS_NAME;}});
\ No newline at end of file
+document.location.pathname+"?"+query;var win=new Ext.Window({title:"Bookmark URL",layout:'form',items:[{xtype:'textfield',fieldLabel:'Permalink',readOnly:true,value:url}],width:300});win.show();return url;},extractConfiguration:function(){var config={};var center=this.map.getCenter();config.map={center:[center.lon,center.lat],zoom:this.map.zoom};config.map.layers=[];this.layers.each(function(layerRecord){var c={title:layerRecord.get("title"),name:(layerRecord.get("layer").params&&layerRecord.get("layer").params.LAYERS)||layerRecord.get("name"),visibility:layerRecord.get("layer").getVisibility()};config.map.layers.push(c);});return config;},displayAppInfo:function(){var win=new Ext.Window({title:"About GeoExplorer",html:"<iframe style=\"border: none; height: 100%; width: 100%\" src=\"about.html\"><a target=\"_blank\" href=\"about.html\">About GeoExplorer</a> </iframe>",modal:true,width:300,height:350});win.show();}});GeoExplorer.Full=Ext.extend(GeoExplorer,{createTools:function(){var tools=GeoExplorer.Full.superclass.createTools.apply(this,arguments);var aboutButton=new Ext.Button({text:"GeoExplorer",iconCls:"icon-geoexplorer",handler:this.displayAppInfo});tools.unshift("-");tools.unshift(new Ext.Button({tooltip:"Bookmark",handler:this.bookmark,scope:this,iconCls:"icon-save"}));tools.unshift(new Ext.Button({tooltip:"Export as blog widget",text:'Export',handler:this.showEmbedWizard,scope:this,iconCls:'icon-save'}));tools.unshift("-");tools.unshift(aboutButton);return tools;},showEmbedWizard:function(){var config=this.extractConfiguration();var finalize=this.makeFinalWizardPane(config);var wizard=new GeoExplorer.Wizard({height:300,width:400,resizable:false,modal:true,title:"Export Map",pages:[{title:'Finish',panel:finalize}]});wizard.show();},makeFinalWizardPane:function(config){var description=new Ext.Panel({html:'<p> Your map is ready to be published to the web! </p>'+'<p> Simply copy the following HTML to embed the map in your website: </p>',border:false});var snippetArea=new Ext.form.TextArea({editable:false,height:'auto'});var heightField=new Ext.form.NumberField({width:50,value:400});var widthField=new Ext.form.NumberField({width:50,value:600});var updateSnippet=function(){snippetArea.setValue('<iframe height="'+heightField.getValue()+' " width="'+widthField.getValue()+'" src="'+
+Ext.urlEncode(config)+'"> </iframe>');};heightField.on("change",updateSnippet);widthField.on("change",updateSnippet);updateSnippet();var snippet=new Ext.Panel({border:false,layout:'fit',items:[snippetArea]});var adjustments=new Ext.Panel({layout:"column",items:[new Ext.Panel({border:false,width:90,items:[new Ext.form.ComboBox({editable:false,width:70,store:new Ext.data.SimpleStore({fields:["name","height","width"],data:[["Mini",100,100],["Small",200,300],["Large",400,600],["Premium",600,800]]}),triggerAction:'all',displayField:'name',value:"Large",mode:'local',listeners:{'select':function(combo,record,index){widthField.setValue(record.get("width"));heightField.setValue(record.get("height"));updateSnippet();}}})]}),{html:"Height",border:false},heightField,{html:"Width",border:false},widthField],border:false});return new Ext.Panel({items:[description,snippet,{html:"Map Size",border:false},adjustments]});}});Ext.namespace("GeoExplorer");GeoExplorer.Embed=Ext.extend(GeoExplorer,{createLayout:function(){this.map=new OpenLayers.Map({allOverlays:true,controls:[new OpenLayers.Control.PanPanel(),new OpenLayers.Control.ZoomPanel()]});var onDoubleClick=function(ctrl,evt){OpenLayers.Event.stop(evt?evt:window.event);};var controls=this.map.controls[0].controls;for(var i=0;i<controls.length;i++){OpenLayers.Event.observe(controls[i].panel_div,"dblclick",OpenLayers.Function.bind(onDoubleClick,this.map.controls[0],controls[i]));}
+this.map.events.on({"preaddlayer":function(evt){if(evt.layer.mergeNewParams){var maxExtent=evt.layer.maxExtent;evt.layer.mergeNewParams({transparent:true,format:"image/png",tiled:true,tilesorigin:[maxExtent.left,maxExtent.bottom]});}},scope:this});var mapConfig=this.initialConfig.map||{};this.mapPanel=new GeoExt.MapPanel({layout:"anchor",border:true,region:"center",map:this.map,center:mapConfig.center&&new OpenLayers.LonLat(mapConfig.center[0],mapConfig.center[1]),zoom:mapConfig.zoom,items:[{xtype:"gx_scaleslider",vertical:true,height:100,plugins:new GeoExt.ScaleSliderTip({template:"<div>Zoom Level: {zoom}</div>"})},this.createMapOverlay()]});this.layers=this.mapPanel.layers;var addLayerButton=new Ext.Button({tooltip:"Add Layers",disabled:true,iconCls:"icon-addlayers",handler:this.showCapabilitiesGrid,scope:this});this.on("ready",function(){addLayerButton.enable();});var toolbar=new Ext.Toolbar({xtype:"toolbar",region:"north",disabled:true,items:this.createTools()});this.on("ready",function(){toolbar.enable();});var viewport=new Ext.Viewport({layout:"fit",hideBorders:true,items:{layout:"border",deferredRender:false,items:[toolbar,this.mapPanel]}});},createTools:function(){var tools=GeoExplorer.Embed.superclass.createTools.apply(this,arguments);var menu=new Ext.menu.Menu();var updateLayerSwitcher=function(){menu.removeAll();menu.addItem(new Ext.menu.TextItem({text:'Layers'}));this.mapPanel.layers.each(function(x){if(x.get("layer").displayInLayerSwitcher){menu.addItem(new GeoExplorer.LayerMenuItem({layerRecord:x}));}});}
+this.mapPanel.layers.on("update",updateLayerSwitcher,this);this.mapPanel.layers.on("remove",updateLayerSwitcher,this);this.mapPanel.layers.on("add",updateLayerSwitcher,this);var layerChooser=new Ext.Button({tooltip:'Layer Switcher',iconCls:'icon-layer-switcher',menu:menu});tools.unshift("-");tools.unshift(layerChooser);var aboutButton=new Ext.Button({tooltip:"About this map",iconCls:"icon-about",handler:this.displayAppInfo});tools.push("->");tools.push(new Ext.Button({tooltip:"Bookmark",handler:this.bookmark,scope:this,iconCls:"icon-save"}));tools.push(aboutButton);return tools;}});Ext.namespace("GeoExplorer");GeoExplorer.Wizard=function(config){Ext.applyIf(config,{layout:'card',activeItem:0,tbar:[],items:[]});for(var i=0,len=config.pages.length;i<len;i++){if(i!==0)config.tbar.push({text:'→',disabled:true});config.tbar.push({text:config.pages[i].title,handler:function(x){return function(){this.layout.setActiveItem(x);this.doLayout();};}(config.items.length),scope:this});config.items.push(config.pages[i].panel);}
+console.log(config);GeoExplorer.Wizard.superclass.constructor.call(this,config);};Ext.extend(GeoExplorer.Wizard,Ext.Window);
\ No newline at end of file
More information about the Commits
mailing list