OpenLayers OpenLayers

Changeset 7731

Show
Ignore:
Timestamp:
08/12/08 21:05:30 (5 months ago)
Author:
architect
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/architect/scripts/controlConfig.js

    r7730 r7731  
    363363    /*If a new layer is being added, do not clear the HTML when the delete button is pressed*/       
    364364        controlsLength++; //A layer has been created, so add 1 to the layersLength (global var to keep track of number of layers 
    365         numActiveLayers++; //Add one to the number of active layers 
     365        numActiveControls++; //Add one to the number of active layers 
    366366    } 
    367367     
     
    831831    $('tb2blcCommon').innerHTML += "<br />Min Rect Size " +  createInputTextBox('layoutControlConfigMinRectSize','minRectSize', "", 2); 
    832832    $('tb2blcCommon').innerHTML += "<br />Title " +  createInputTextBox('layoutControlConfigTitle','title', "", 30); 
     833    $('tb2blcCommon').innerHTML += "<br />Maximize Control " +  createSelectList('layoutControlConfigMaximize', 'maximize', '', getTrueMenu()); 
    833834} 
    834835 
  • sandbox/architect/scripts/saveMap.js

    r7730 r7731  
    108108                finalLayerOptions = ''; 
    109109                finalLayerParams = ''; 
    110                 generatedCode += '\n<br\>\n'; 
     110                generatedCode += '\n<br/>\n'; 
    111111                /*------------------- 
    112112                | Google / Yahoo / VE 
     
    242242            }//end loop 
    243243             
    244              
    245244            /*------------------- 
    246245            | Generate Control code 
    247246            |--------------------*/ 
    248             /*store the layers to generate the code*/ 
     247             
     248            /*store the controls*/ 
    249249            for(i = 0; i < divs.div.length; i++){ 
    250250                for(j = 0; j < map.controls.length; j++){ 
     
    256256                    } 
    257257                } 
     258                 
     259                /*store panels*/ 
    258260                for(j = 0; j < panels.panels.length; j++){ 
    259261                    if(panels.panels[j] != null){ 
     
    266268            }        
    267269             
     270            /*Get all the control properties for the current control*/ 
     271            /*extend this?*/ 
     272            var finalControlOptions = []; 
     273            for(i = 0; i < finalMap.controls.length; i++){ 
     274                finalControlOptions[i] = ''; 
     275                for(j in finalMap.controls[i]){ 
     276                    if(j != "id" && j != "CLASS_NAME" && j != "id" && j != "panelID" && j != "title" && j != "xPos" && j != "yPos" && j != "width" && j != "height"){ 
     277                        if( hasQuotes(finalMap.controls[i][j]) == true) 
     278                            finalControlOptions[i] += "\n" + j + ":" + finalMap.controls[i][j] + ","; //no quotes if int 
     279                        else 
     280                            finalControlOptions[i] += "\n" + j + ": '" + finalMap.controls[i][j] + "',"; 
     281                    } 
     282                }                
     283                 
     284                if (finalControlOptions[i].substr(finalControlOptions[i].length - 1) == ",") 
     285                    finalControlOptions[i] = finalControlOptions[i].substr(0, finalControlOptions[i].length - 1) //get rid of the trailing comma 
     286            } 
     287             
     288             
     289            /*Get all the panel properties for the current panel*/ 
     290            /*extend this?*/ 
     291            var finalPanelOptions = []; 
     292            for(i = 0; i < finalMap.panels.length; i++){ 
     293                finalControlOptions[i] = ''; 
     294                for(j in finalMap.panels[i]){ 
     295                    if(j != "id" && j != "CLASS_NAME" && j != "id" && j != "panelID" && j != "title" && j != "xPos" && j != "yPos" && j != "width" && j != "height"){ 
     296                        if( hasQuotes(finalMap.panels[i][j]) == true) 
     297                            finalControlOptions[i] += "\n" + j + ":" + finalMap.panels[i][j] + ","; //no quotes if int 
     298                        else 
     299                            finalControlOptions[i] += "\n" + j + ": '" + finalMap.panels[i][j] + "',"; 
     300                    } 
     301                }                
     302                 
     303                if (finalControlOptions[i].substr(finalControlOptions[i].length - 1) == ",") 
     304                    finalControlOptions[i] = finalControlOptions[i].substr(0, finalControlOptions[i].length - 1) //get rid of the trailing comma 
     305            } 
     306             
    268307            /*generate the code*/ 
    269308            var controlName = ""; 
    270             var finalLayerOptions = ""; 
    271309            var cTitle = ""; 
    272310             
    273             generatedCode += '\n<br\>\n'; 
     311            generatedCode += '\n<br/>\n'; 
    274312             
    275313            //Loop through all the valid controls 
    276             for(i = 0; i < finalMap.controls.length; i++){                           
    277                 finalControlOptions = ''; 
    278                  
    279                 generatedCode += '\n<br\>\n'; 
     314            for(i = 0; i < finalMap.controls.length; i++){                                           
     315                generatedCode += '\n<br/>\n'; 
    280316                cTitle = finalMap.controls[i].title.replace(/\s+/g,''); 
    281                 generatedCode += "var control_" +  cTitle + "_" + i + " = new " + finalMap.controls[i].CLASS_NAME + "({" 
    282                     + finalControlOptions + "});";  
    283             } 
    284              
    285             generatedCode += '\n<br\>'; 
     317                if(finalMap.controls[i].panelID == null){ //no panel, so just add the control 
     318                    generatedCode += "var control_" +  cTitle + "_" + i + " = new " + finalMap.controls[i].CLASS_NAME + "({" 
     319                        + finalControlOptions[i] + "});<br/>";  
     320                    generatedCode += "map.addControl(control_" +  cTitle + "_" + i + ");"; 
     321                } 
     322            } 
     323             
     324            generatedCode += '\n<br /><br />'; 
     325            var cToPanel = ''; 
    286326            //Loop through all the valid panels 
    287327            for(i = 0; i < finalMap.panels.length; i++){                             
    288328                finalPanelOptions = ''; 
    289                  
    290                 generatedCode += '\n<br\>'; 
     329                generatedCode += '\n<br />'; 
    291330                cTitle = finalMap.panels[i].title.replace(/\s+/g,''); 
     331                //create the panel 
    292332                generatedCode += "var panel_" +  cTitle + "_" + i + " = new " + finalMap.panels[i].CLASS_NAME + "({" 
    293                     + finalPanelOptions + "});";  
     333                    + finalPanelOptions + "});\n<br />";  
     334                //add controls the panel 
     335                generatedCode += "<br />panel_" +  cTitle + "_" + i + ".addControls([<br />"; 
     336                cToPanel = ''; 
     337                for(j = 0; j < finalMap.controls.length; j++){ 
     338                    if(finalMap.controls[j].panelID == finalMap.panels[i].id){ 
     339                        cToPanel += "new " + finalMap.controls[i].CLASS_NAME + "(" 
     340                        + finalControlOptions[i] + "),<br/>";  
     341                    } 
     342                } 
     343                console.log(cToPanel); 
     344                if (cToPanel.substr(cToPanel.length - 1) == ">"){ 
     345                    cToPanel = cToPanel.substr(0, cToPanel.length - 6) //get rid of the trailing comma 
     346                    cToPanel += "<br />"; //add the break 
     347                } 
     348                 
     349                generatedCode += cToPanel + "]);<br />" 
     350                +   "map.addControl(panel_" +  cTitle + "_" + i + ");<br/>"; 
    294351            } 
    295352             
     
    299356            |--------------------*/ 
    300357            /*Add layers to map*/ 
    301             generatedCode += "\n<br\>\n<br\> map.addLayers(["; 
     358            generatedCode += "\n<br/>\n<br/> map.addLayers(["; 
    302359            for(i=0; i < finalMap.layers.length; i++){ 
    303360                if(i != finalMap.layers.length - 1) 
     
    309366             
    310367             
     368                         
    311369            /*Set map center*/ 
    312370            if(map.lat != null && map.lon != null){ 
    313                 generatedCode += "\n\n map.setCenter(new OpenLayers.LonLat(" + map.lon + ", " + map.lat + ")"; //Use lat lon if specified 
     371                generatedCode += "\n\n<br/> map.setCenter(new OpenLayers.LonLat(" + map.lon + ", " + map.lat + ")"; //Use lat lon if specified 
    314372                if (map.zoom != null) 
    315373                    generatedCode += ", " + map.zoom; 
     
    319377            } 
    320378            else //set to max extent 
    321                 generatedCode += "\n\n map.zoomToMaxExtent()"; 
     379                generatedCode += "\n\n<br/> map.zoomToMaxExtent()"; 
    322380             
    323381            $('mapContainer').innerHTML = "<div style='padding:10px;'>" + generatedCode + "</div>";