OpenLayers OpenLayers

Changeset 7709

Show
Ignore:
Timestamp:
08/07/08 11:44:42 (3 weeks ago)
Author:
architect
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/architect/index.php

    r7698 r7709  
    2323    <script type="text/javascript" src="scripts/panelConfig.js"></script> 
    2424    <script type="text/javascript" src="scripts/controlConfig.js"></script> 
     25    <script type="text/javascript" src="scripts/saveMap.js"></script> 
    2526 
    2627    <title>OL Architect - Open Layers Map Creation Application</title> 
     
    184185     
    185186            </div> 
     187            <div id="mapFunctions"> 
     188                <div class="padding5px alignRight"> 
     189                    <form action="index.php" method="post"> 
     190                        <input id="saveMapButton" type="button" value="Save and Create Map" /> 
     191                    </form> 
     192                </div> 
     193            </div> 
    186194        </div> 
    187195    </div> 
  • sandbox/architect/scripts/controlConfig.js

    r7698 r7709  
    7171        /*If false is returned, then the validation in the function failed*/ 
    7272        if($('tb1ControlListDropdown').selectedIndex == 0){ 
    73             alert("A control must be selected"); 
     73            $('siteAlerts').setStyle('display', 'block'); 
     74            $('siteAlerts').setStyle('opacity',0); 
     75            $('siteAlerts').fade(1); 
     76            $('siteAlerts').innerHTML = "A control must be selected"; 
    7477            return; 
     78        } 
     79        if( $('siteAlerts').getStyle('opacity') > 0 ){ 
     80            $('siteAlerts').fade(0); 
    7581        } 
    7682        //populate toolbox2 
  • sandbox/architect/scripts/dragdrop.js

    r7698 r7709  
    5757    /*Create the HTML*/ 
    5858    /*create the draggable box*/ 
    59     if(panelCreated == true){ 
    60     $('mapContainer').innerHTML =   "<div id='draggableDiv'>Drag</div>" 
    61                     +"<div id='draggableDivContainer'>" 
    62                     +"  <div id='draggableDivResize'></div>" 
     59    if(panelCreated == true){ //create html for the panel 
     60        $('mapContainer').innerHTML =   "<div id='draggableDiv'>Drag</div>" 
     61                        +"<div id='draggableDivContainer'>" 
     62                        +"  <div id='draggableDivResize'></div>" 
     63                        +"  <div id='draggableDivTitle'>" + theName + "</div>" 
     64                        +"</div>"; 
     65        $('draggableDivResize').addEvent('click', function(event){ 
     66        if( $('siteAlerts').getStyle('opacity') > 0 ){ 
     67            $('siteAlerts').fade(0); 
     68        } 
     69    }); 
     70    } 
     71    else if(panelCreated == false){ //create html for the control 
     72        $('mapContainer').innerHTML =   "<div id='draggableDivContainer'>" 
    6373                    +"  <div id='draggableDivTitle'>" + theName + "</div>" 
    6474                    +"</div>"; 
    6575    } 
    66     else if(panelCreated == false){ 
    67     $('mapContainer').innerHTML =   "<div id='draggableDivContainer'>" 
    68                     +"  <div id='draggableDivTitle'>" + theName + "</div>" 
    69                     +"</div>"; 
    70     } 
     76     
    7177    var boxID; 
    7278    var exists = false; 
    7379    var boxStyle = []; 
    74     /*load data, if it exists*/ 
     80    /*load data, if it exists - only looking for panel here*/ 
    7581    for(var i = 0; i < divs.div.length; i++){ 
    7682        if(divs.div[i].pID == pID){ 
     
    7884            exists = true; 
    7985        } 
    80         /*if(divs.div[i].cID == cID && cID != 'z'){ 
    81             boxID = i; 
    82             exists = true; 
    83         }*/ 
    8486    } 
    8587    //console.log("pID: " + pID + " | cID:" + cID + " | boxID: " + boxID); 
     
    182184            } 
    183185        }); 
     186    }//end if panel created 
     187    if(panelCreated == false){ 
     188        var controlExists = false; 
     189        $('draggableDivTitle').fade(.2); //fade the panel name 
     190        var controlBox = new Element('div', {'id':'curControlBox' + cID, 'class':'controlBox'}); //store the controlBox div in a variable 
     191        $('draggableDivContainer').adopt(controlBox); //add the controlbox to the panel container 
     192        for(var i = 0; i < divs.div.length; i++){ //see if a control already exists 
     193            if(divs.div[i].cID == cID && cID != 'z'){ 
     194                boxID = i; 
     195                controlExists = true 
     196            } 
     197        } 
     198        if(controlExists == true){ 
     199            /*for(var i = 0; i < divs.div.length; i++){ //see if a control already exists 
     200                if(divs.div[i].cID != 'z'){ 
     201                    var curControlBoxID = 'curControlBox' + i; 
     202                    $(curControlBoxID).setStyle('left', divs.div[boxID].xPos + "px"); 
     203                    $(curControlBoxID).setStyle('top', divs.div[boxID].yPos + "px"); 
     204                    $(curControlBoxID).setStyle('width', divs.div[boxID].width + "px"); 
     205                    $(curControlBoxID).setStyle('height', divs.div[boxID].height + "px"); 
     206                    $(curControlBoxID).innerHTML = divs.div[boxID].name;     
     207                } 
     208            }*/ 
     209         
     210            var curControlBoxID = 'curControlBox' + cID; 
     211            $(curControlBoxID).setStyle('left', divs.div[boxID].xPos + "px"); 
     212            $(curControlBoxID).setStyle('top', divs.div[boxID].yPos + "px"); 
     213            $(curControlBoxID).setStyle('width', divs.div[boxID].width + "px"); 
     214            $(curControlBoxID).setStyle('height', divs.div[boxID].height + "px"); 
     215            $(curControlBoxID).innerHTML = divs.div[boxID].name; 
     216        } 
     217        populateMapControls(controlExists, boxID, true); //create the inputs for the control box 
     218         
    184219    } 
    185220}; 
    186221 
     222 
     223/*======================= 
     224| editElementConfig() 
     225| 
     226| handles the input text boxes that configure the x,y,width, and height of a dragbox 
     227| 
     228=========================*/ 
    187229function editElementConfig(){ 
    188230/*calculate the limits to ensure the draggable box remains within the mapContainer*/ 
     
    217259function emptyMapControls() { 
    218260    $('mapControls').innerHTML = ""; 
    219 
    220 function populateMapControls(exists, boxID){ 
     261    $('mapControls').setStyle('border', 'none'); 
     262     
     263    var mapFuncPos = $('mapControls').offsetTop + $('mapControls').offsetHeight; 
     264    $('mapFunctions').setStyle('top', mapFuncPos - 10); 
     265
     266function populateMapControls(exists, boxID, control){ 
    221267    $('mapControls').innerHTML =   "<form id='mapControlsForm'>" 
    222268                    +"  X Position:<input id='elementX' type='text' value='0' size='3'>" 
     
    228274                    +"  <input id='editElement' onclick='editElementConfig();' type='button' value='Save' />" 
    229275                    +"</form>"; 
     276    $('mapControls').setStyle('border', '1px solid #415e69'); 
     277     
     278    var mapFuncPos = $('mapControls').offsetTop + $('mapControls').offsetHeight; 
     279    $('mapFunctions').setStyle('top', mapFuncPos); 
     280     
     281    if(control == true){ //if a control was created 
     282        $('elementWidth').value = 26; 
     283        $('elementHeight').value = 26; 
     284    } 
    230285    if(exists == true){ 
    231286        $('elementX').value = divs.div[boxID].xPos; 
  • sandbox/architect/scripts/layerConfig.js

    r7548 r7709  
    1616        /*If false is returned, then the validation in the function failed*/ 
    1717        if ($('tb1LayerListDropdown').selectedIndex == 0){ 
    18             alert("A layer service must be selected"); 
     18            $('siteAlerts').setStyle('display', 'block'); 
     19            $('siteAlerts').setStyle('opacity',0); 
     20            $('siteAlerts').fade(1); 
     21            $('siteAlerts').innerHTML = "A layer service must be selected"; 
    1922            return; 
    2023        } 
    21         if ($('tb1NewLayerForm').value == ""){ 
    22             alert("A valid name must be entered"); 
     24         
     25        /*override the trim function*/ 
     26        String.prototype.trim = function() { 
     27            return this.replace(/^\s+|\s+$/g,""); 
     28        } 
     29        /*store the trimmed name*/ 
     30        var trimedLayerName = $('tb1NewLayerForm').value.trim(); 
     31         
     32        /*if nothing but spaces were entered*/ 
     33        if (trimedLayerName == ""){ 
     34            $('siteAlerts').setStyle('display', 'block'); 
     35            $('siteAlerts').setStyle('opacity',0); 
     36            $('siteAlerts').fade(1); 
     37            $('siteAlerts').innerHTML = "A valid name must be entered"; 
    2338            return; 
    2439        } 
     40         
     41        /*something went right!*/ 
     42        if( $('siteAlerts').getStyle('opacity') > 0 ){ 
     43            $('siteAlerts').fade(0); 
     44        } 
     45        //If a control or panel is in the map area, clear it out 
     46        emptyMapDrag(); 
     47        emptyMapControls(); 
    2548        createBaseLayerConfig(); 
    2649        /*When the save button is clicked when the layer is first added, add a list item to the layer list in toolbox1*/ 
  • sandbox/architect/scripts/mapConfig.js

    r7561 r7709  
    11/*When everything is loaded, attach events to elements*/ 
     2var isMapNew = true; 
     3 
    24window.addEvent('domready', function() { 
    35    /*control*/ 
     
    57        /*When the new control button is clicked, populate toolbox2. */ 
    68        //populate toolbox2 
    7         createBaseMapConfig(); 
     9        createBaseMapConfig(isMapNew); 
     10        if( $('siteAlerts').getStyle('opacity') > 0 ){ 
     11            $('siteAlerts').fade(0); 
     12        } 
     13        //If a control or panel is in the map area, clear it out 
     14        emptyMapDrag(); 
     15        emptyMapControls(); 
    816        $('saveButton').addEvent('click', function(e) { 
    917            e.stop(); 
     
    2432| populates configuration options 
    2533=========================*/ 
    26 function createBaseMapConfig(){ 
     34function createBaseMapConfig(isNew){ 
    2735/*store the toolbox div in tbid (toolboxid)*/ 
    2836    var tbid = $('toolBox2Content'); 
     
    4452    /*Populate ToolBox 2's layer options with the layer selected in ToolBox 1's layer list dropdown - call changeLayer and pass in the controlList from toolbox1*/ 
    4553        //name, id 
    46         populateMap(tb1MapName.value);     
     54        populateMap(tb1MapName.value, isNew);  
    4755} 
    4856 
     
    5260| populates the map with empty settings 
    5361=========================*/ 
    54 function populateMap(mName){ 
     62function populateMap(mName, isNew){ 
    5563    $('tb2blcCommon').innerHTML += "Map Name: " + createInputTextBox('layoutMapConfigTitle','title', mName, 30); 
    5664    $('tb2blcCommon').innerHTML += "<br /> Theme " +  createSelectList('layoutMapConfigTheme', 'theme', '', getThemeMenu()); 
     
    6573    $('tb2blcCommon').innerHTML +="<br/>Projection " + createInputTextBox('layoutMapConfigProjection','projection', '', 15); 
    6674     
    67     $('tb2blcCommon').innerHTML += "<br/><br/><strong>Center</strong><br/> Lon" + createInputTextBox('layoutMapConfigLon','lon', '', 2) + " Lat" + createInputTextBox('layoutMapConfigLat','lat', '', 2) + "<br /> Zoom" + createInputTextBox('layoutMapConfigZoom','zoom', '', 2) + " Dragging" + createSelectList('layoutControlConfigDragging', 'dragging', '', getNullMenu()); 
     75    $('tb2blcCommon').innerHTML += "<br/><br/><strong>Center</strong><br/> Lon" + createInputTextBox('layoutMapConfigLon','lon', '', 2) + " Lat" + createInputTextBox('layoutMapConfigLat','lat', '', 2) + "<br /> Zoom" + createInputTextBox('layoutMapConfigZoom','zoom', '', 2) + " Dragging" + createSelectList('layoutControlConfigDragging', 'dragging', '', getFalseMenu()); 
    6876     
    6977    $('tb2blcCommon').innerHTML += "<br/><br/><strong>Extents</strong><br/><strong>Max Extent</strong><br/> MinX" + createInputTextBox('layoutMapConfigMaxExtenMinX','MaxExtentMinX', '', 2) + " MinY" + createInputTextBox('layoutMapConfigMaxExtentMinY','MaxExtentMinY', '', 2) + "<br/>MaxX" + createInputTextBox('layoutMapConfigMaxExtentMaxX','MaxExtentMaxX', '', 2) + " MaxY" + createInputTextBox('layoutMapConfigMaxExtentMaxY','MaxExtentMaxY', '', 2); 
     
    7482    $('tb2blcCommon').innerHTML +="<br/><br/>Units " + createSelectList('layoutMapConfigUnits','units', "",  getUnits()); 
    7583     
    76     $('tb2blcCommon').innerHTML +="<br/><br/>Max Resolution " + createInputTextBox('layoutMapConfigMaxResolution','maxResolution', '', 2); 
    77     $('tb2blcCommon').innerHTML +="<br/>Min Resolution " + createInputTextBox('layoutMapConfigMinResolution','minResolution', '', 2); 
     84    $('tb2blcCommon').innerHTML +="<br/><br/>Max Resolution " + createInputTextBox('layoutMapConfigMaxResolution','maxResolution', '', 7); 
     85    $('tb2blcCommon').innerHTML +="<br/>Min Resolution " + createInputTextBox('layoutMapConfigMinResolution','minResolution', '', 7); 
    7886    $('tb2blcCommon').innerHTML +="<br/>Resolutions " + createInputTextBox('layoutMapConfigResolutions','resolutions', '', 30); 
    7987     
     
    8492     
    8593    $('tb2blcCommon').innerHTML +="<br/><br/>Fall Through " + createSelectList('mapConfigFallthrough', 'fallThrough', '', getTrueMenu());    
     94    $('tb2blcCommon').innerHTML +="<br/><br/>Fractional Zoom" + createSelectList('mapConfigFractionalZoom', 'fractionalZoom', '', getTrueMenu());    
     95     
     96    populateMapValues(isNew); 
    8697} 
    8798 
     
    125136    /*Highlist the layer in the layer list that was saved*/ 
    126137    $('tb1NewMap').highlight('#567D8C', '#9D9483');  
    127 
     138     
     139    isMapNew = false; 
     140
     141 
     142 
     143 
     144/*======================= 
     145|  populateControlValues(ID, controlName, isControlNew) 
     146
     147|used to fill in default values from OpenLayers.prototype or values stored in the map object, if the layer already exists 
     148
     149|ID is the id of the current layer - an integer 
     150|controlName is the name of the layer service which coresponds with OpenLayers.Control.controlName.prototype 
     151|isControlNew determines if the layer is a newly created one or already exists 
     152=========================*/ 
     153/*Warning:Confusion follows*/ 
     154/*Because some values in OL are set as 'false' by default we check to see if the prototype != null*/ 
     155function populateMapValues(isNew){ 
     156    /*by default, we assuse the isControlNew is "new"*/ 
     157    if(isNew == undefined || isNew == null) 
     158        isNew = true; 
     159             
     160    /*pull values from OpenLayers*/ 
     161    /*Loop through the common values*/ 
     162    // theme - var curDropDownVal = $('tb2ControlListDropdown').value; 
     163    for (var i = 0; i < $('tb2blcCommon').childNodes.length; i++){ 
     164        /*set a variable equal to the current node*/ 
     165        var tempNode = $('tb2blcCommon').childNodes[i]; 
     166        /*if the childnode has an ID, then it is an input which we will get a value from to put in the map object*/ 
     167        if (tempNode.type == "text"){ 
     168        //By default, set the value to nothing.  If something exists, override the null value 
     169            tempNode.value = ''; 
     170            /*Get the map name value*/ 
     171            if(OpenLayers.Map.prototype[tempNode.name] != null){ 
     172                tempNode.value = OpenLayers.Map.prototype[tempNode.name]; 
     173            } 
     174            $(tempNode).erase('class'); //clear the ValueUpdated class - it won't think the value is updated     
     175        }    
     176        /* SELECT LIST*/ 
     177        else if(tempNode.type == "select-one" ){ 
     178            //By default, set the value to 0.  Override the value is necessary 
     179            tempNode.selectedIndex = 0;  
     180            if(OpenLayers.Map.prototype[tempNode.name] != null){ 
     181                var olVal = OpenLayers.Map.prototype[tempNode.name]; 
     182                /*check for True / False lists*/ 
     183                if(tempNode.options[0].value == "True" || tempNode.options[0].value == ''){ 
     184                    if( Boolean(tempNode.options[0].name) == olVal){ 
     185                        tempNode.selectedIndex = 0; 
     186                        } 
     187                    if( Boolean(tempNode.options[1].name) == olVal){ 
     188                        tempNode.selectedIndex = 1; 
     189                        } 
     190                } 
     191                /*check for Jpg / Gif / Png, and other type of lists*/ 
     192                else{ 
     193                    if(tempNode.options[0].value == olVal) 
     194                            tempNode.selectedIndex = 0; 
     195                    if(tempNode.options[1].value == olVal) 
     196                            tempNode.selectedIndex = 1; 
     197                    if(tempNode.options[2]){ 
     198                        if(tempNode.options[2].value == olVal) 
     199                            tempNode.selectedIndex = 2; 
     200                    } 
     201                    if(tempNode.options[3]){ 
     202                        if(tempNode.options[3].value == olVal) 
     203                            tempNode.selectedIndex = 3; 
     204                    } 
     205                } 
     206                $(tempNode).erase('class'); //clear the ValueUpdated class - it won't think the value is updated     
     207            } 
     208        } 
     209    } 
     210 
     211     
     212    /*If the layer is not new, grab values from the map object*/ 
     213    if(isNew == false){ 
     214        /*Loop through the common values*/ 
     215        for (var i = 0; i < $('tb2blcCommon').childNodes.length; i++){ 
     216            /*set a variable equal to the current node*/ 
     217            var tempNode = $('tb2blcCommon').childNodes[i]; 
     218            /*if the childnode has an ID, then it is an input which we will get a value from to put in the map object*/ 
     219            if (tempNode.type == "text" || tempNode.type == "select-one" ){ 
     220                    /*Get the map name value*/ 
     221                    var mapLayerVal = map[tempNode.name]; 
     222                    /*If there is valid data, fill in the current form*/ 
     223                    if(mapLayerVal != undefined || mapLayerVal != null){ 
     224                        tempNode.value = map[tempNode.name]; 
     225                    } 
     226                    else{ 
     227                        //tempNode.value = ''; 
     228                        if(tempNode.type == "select-one" ) 
     229                            tempNode.selectedIndex = 0; 
     230                        $(tempNode).erase('class'); //clear the class - it won't think the value is updated 
     231                    } 
     232            } 
     233        } 
     234    } 
     235     
     236    //Set the selected panel in the toolbox2 equal to the selected panel in toolbox1 
     237    //$('tb2ControlListPanelDropdown').selectedIndex = $('tb1ControlListPanelDropdown').selectedIndex; 
     238    //pID = $('tb2ControlListPanelDropdown').options[$('tb2ControlListPanelDropdown').selectedIndex].id; 
     239    //createDragBox(ID, pID, controlName); 
     240
  • sandbox/architect/scripts/panelConfig.js

    r7697 r7709  
    4141        /*If false is returned, then the validation in the function failed*/ 
    4242        if($('tb1NewPanelForm').value == ''){ 
    43             alert("A name must be entered."); 
     43            $('siteAlerts').setStyle('display', 'block'); 
     44            $('siteAlerts').setStyle('opacity',0); 
     45            $('siteAlerts').fade(1); 
     46            $('siteAlerts').innerHTML = "A panel name must be entered"; 
    4447            return; 
     48        } 
     49        if( $('siteAlerts').getStyle('opacity') > 0 ){ 
     50            $('siteAlerts').fade(0); 
    4551        } 
    4652        //populate toolbox2 
  • sandbox/architect/style.css

    r7698 r7709  
    463463    #mapControls { 
    464464        background-color:#8C8372; 
     465        left:370px; 
     466        margin-top:10px; 
     467        position:absolute; 
     468        top:510px; 
     469        width:630px; 
     470    } 
     471    #mapFunctions { 
     472        background-color:#8C8372; 
    465473        border:1px solid #415e69; 
    466474        left:370px; 
     
    483491        width:250px; 
    484492    } 
     493    /*======================= 
     494    |   Draggable  Boxes 
     495    =========================*/ 
     496    #draggableDivContainer { 
     497        background-color:#504B42; 
     498        height:80px;     
     499        left:0px; 
     500        /*overflow:hidden*/ 
     501        position:relative; 
     502        top:0px;     
     503        width:100px; 
     504        z-index:1; 
     505    } 
     506      
     507    #draggableDiv { 
     508        background:#628D9D; 
     509        border:1px solid #415E69; 
     510        cursor:move; 
     511        height:25px;     
     512        left:-2px; 
     513        position:absolute; 
     514        text-align:center; 
     515        top:-25px; 
     516        width:100%;  
     517        z-index:6; 
     518    } 
     519 
     520    #draggableDivResize { 
     521        background:#efefef url(images/resize.png); 
     522        bottom:0px; 
     523        cursor:se-resize; 
     524        height:15px; 
     525        position:absolute; 
     526        right:0px; 
     527        width:15px; 
     528        z-index:999; 
     529    } 
     530    #draggableDivTitle { 
     531        background:#567D8C; 
     532        font-size:.9em; 
     533        margin:0px auto; 
     534        left:20%; 
     535        padding:5px; 
     536        position:absolute; 
     537        text-align:center; 
     538        top:40%; 
     539        z-index:4; 
     540    } 
     541    .controlBox { 
     542        background-color:#567D8C; 
     543        font-size:.9em; 
     544        height:26px; 
     545        float:left; 
     546        width:26px; 
     547    } 
    485548/*======================= 
    486549|   Bottom  
     
    497560|  
    498561--------------------------------------------------------------------*/ 
    499 /*======================= 
    500 |   Div Classes 
    501 =========================*/ 
    502 #draggableDivContainer { 
    503     background-color:#504B42; 
    504     height:80px;     
    505     left:0px; 
    506     /*overflow:hidden*/ 
    507     position:relative; 
    508     top:0px;     
    509     width:100px; 
    510     z-index:1; 
    511 } 
    512   
    513 #draggableDiv { 
    514     background:#628D9D; 
    515     border:1px solid #415E69; 
    516     cursor:move; 
    517     height:25px;     
    518     left:-2px; 
    519     position:absolute; 
    520     text-align:center; 
    521     top:-25px; 
    522     width:100%;  
    523     z-index:6; 
    524 } 
    525  
    526 #draggableDivResize { 
    527     background:#efefef url(images/resize.png); 
    528     bottom:0px; 
    529     cursor:se-resize; 
    530     height:15px; 
    531     position:absolute; 
    532     right:0px; 
    533     width:15px; 
    534     z-index:999; 
    535 } 
    536 #draggableDivTitle { 
    537     background:#567D8C; 
    538     margin:0px auto; 
    539     left:20%; 
    540     padding:5px; 
    541     position:absolute; 
    542     text-align:center; 
    543     top:40%; 
    544     z-index:4; 
    545 } 
    546562     
    547563/*======================= 
     
    674690    padding:5px;     
    675691} 
    676 .paddingtop5px { 
    677     padding:5px; 
    678 } 
    679692.padding10px { 
    680693    padding:10px;