[OpenLayers-Dev] Adding css elements in javascript not working

pdecker paulad at rmi.net
Fri Dec 14 07:59:08 EST 2007


Hello Andreas,

I think I am already implementing what you've suggested.  Here is my code
below.

<html>
<head>
    <link rel="stylesheet" href="../theme/default/style.css" type="text/css"
/>
    <style type="text/css">
		div.olControlMousePosition {
			background-color: #ffffff; 
			font-size: smaller;
			font-weight: bold;
		}        
		.olControlOverviewMapContainer {
			position: absolute;
			bottom: 40px;
			right: 0px;
		}        
		.olControlOverviewMapMinimizeButton {
			right: 0px;	
			bottom: 90px;
		}    
		.olControlOverviewMapMaximizeButton {
			right: 0px;
			bottom: 90px;
		}
    </style>
    <script src="./lib/OpenLayers.js"></script>
    
    <script type="text/javascript">
        var map, wms;
		
         ......
		
        function init(){
           .............

			// Build the map.                        
			var options = { maxResolution: maxRes,
				            numZoomLevels: zoomLevels,
				            controls:[]
				          };
			
            map = new OpenLayers.Map('map', options);

			map.addControl(nav);   /nav created elsewhere
			
            map.addControl(new OpenLayers.Control.PanZoomBar());
           
            map.addControl(mp);   //mp created elsewhere
            
			wms = new OpenLayers.Layer.WMS( "WMS Image", 
					........);

			map.addLayer(wms);

			var options2 = {
				layers: [wms.clone()],
				minRatio: 8,
				maxRatio: 32
			};

			map.addControl(new OpenLayers.Control.OverviewMap(options2));
			
            map.setCenter(new OpenLayers.LonLat(lon, lat), newZoom);
        }
    </script>


Thanks.



Andreas Hocevar-2 wrote:
> 
> Hi,
> 
> Tim Schaub wrote:
>> Hey-
>>
>> pdecker wrote:
>>   
>>> I have tried to modify some of the css elements as shown below.  The
>>> div.olControlMousePosition works, but the OverviewMap elements do not
>>> work. 
>>> If I  modify the OpenLayers style.css file itself, the elements work.  I
>>> am
>>> using OpenLayer 2.5.  Thanks for any help.  -Paula
>>>     
>> Try adding theme: null as an option in your map constructor.
>>
>> var map = new OpenLayers.Map("map", {theme: null});
>>
>> If this works, please file a ticket reporting that the stylesheet 
>> detection is flawed (as I already suspect it is).
>>   
> 
> We had the same issue with the OverviewMap in Mapbuilder. We solved it
> by adding the stylesheet prior to initializing the OpenLayers map. Don't
> know if this information is helpful for you.
> 
> Regards,
> Andreas.
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-css-elements-in-javascript-not-working-tp14316592p14335422.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.




More information about the Dev mailing list