Changeset 7731
- Timestamp:
- 08/12/08 21:05:30 (5 months ago)
- Files:
-
- sandbox/architect/scripts/controlConfig.js (modified) (2 diffs)
- sandbox/architect/scripts/saveMap.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/architect/scripts/controlConfig.js
r7730 r7731 363 363 /*If a new layer is being added, do not clear the HTML when the delete button is pressed*/ 364 364 controlsLength++; //A layer has been created, so add 1 to the layersLength (global var to keep track of number of layers 365 numActive Layers++; //Add one to the number of active layers365 numActiveControls++; //Add one to the number of active layers 366 366 } 367 367 … … 831 831 $('tb2blcCommon').innerHTML += "<br />Min Rect Size " + createInputTextBox('layoutControlConfigMinRectSize','minRectSize', "", 2); 832 832 $('tb2blcCommon').innerHTML += "<br />Title " + createInputTextBox('layoutControlConfigTitle','title', "", 30); 833 $('tb2blcCommon').innerHTML += "<br />Maximize Control " + createSelectList('layoutControlConfigMaximize', 'maximize', '', getTrueMenu()); 833 834 } 834 835 sandbox/architect/scripts/saveMap.js
r7730 r7731 108 108 finalLayerOptions = ''; 109 109 finalLayerParams = ''; 110 generatedCode += '\n<br \>\n';110 generatedCode += '\n<br/>\n'; 111 111 /*------------------- 112 112 | Google / Yahoo / VE … … 242 242 }//end loop 243 243 244 245 244 /*------------------- 246 245 | Generate Control code 247 246 |--------------------*/ 248 /*store the layers to generate the code*/ 247 248 /*store the controls*/ 249 249 for(i = 0; i < divs.div.length; i++){ 250 250 for(j = 0; j < map.controls.length; j++){ … … 256 256 } 257 257 } 258 259 /*store panels*/ 258 260 for(j = 0; j < panels.panels.length; j++){ 259 261 if(panels.panels[j] != null){ … … 266 268 } 267 269 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 268 307 /*generate the code*/ 269 308 var controlName = ""; 270 var finalLayerOptions = "";271 309 var cTitle = ""; 272 310 273 generatedCode += '\n<br \>\n';311 generatedCode += '\n<br/>\n'; 274 312 275 313 //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'; 280 316 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 = ''; 286 326 //Loop through all the valid panels 287 327 for(i = 0; i < finalMap.panels.length; i++){ 288 328 finalPanelOptions = ''; 289 290 generatedCode += '\n<br\>'; 329 generatedCode += '\n<br />'; 291 330 cTitle = finalMap.panels[i].title.replace(/\s+/g,''); 331 //create the panel 292 332 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/>"; 294 351 } 295 352 … … 299 356 |--------------------*/ 300 357 /*Add layers to map*/ 301 generatedCode += "\n<br \>\n<br\> map.addLayers([";358 generatedCode += "\n<br/>\n<br/> map.addLayers(["; 302 359 for(i=0; i < finalMap.layers.length; i++){ 303 360 if(i != finalMap.layers.length - 1) … … 309 366 310 367 368 311 369 /*Set map center*/ 312 370 if(map.lat != null && map.lon != null){ 313 generatedCode += "\n\n map.setCenter(new OpenLayers.LonLat(" + map.lon + ", " + map.lat + ")"; //Use lat lon if specified371 generatedCode += "\n\n<br/> map.setCenter(new OpenLayers.LonLat(" + map.lon + ", " + map.lat + ")"; //Use lat lon if specified 314 372 if (map.zoom != null) 315 373 generatedCode += ", " + map.zoom; … … 319 377 } 320 378 else //set to max extent 321 generatedCode += "\n\n map.zoomToMaxExtent()";379 generatedCode += "\n\n<br/> map.zoomToMaxExtent()"; 322 380 323 381 $('mapContainer').innerHTML = "<div style='padding:10px;'>" + generatedCode + "</div>";
