[OpenLayers-Users] RV: IE7 screen resizing and map center....

Leonel GMAIL leorochadecastro at gmail.com
Sun Jul 6 16:26:55 EDT 2008


Hi, this is the example code: 

<html> 

    <head> 

        <script
src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAoWFQ587aDQE2aqveHF
Io1RSFu8ji90CZ6uNtEZdDuJ-963N6qRT3ahvG_CiB-pKcD4UYpEzanA8A0w'></script> 
        <script src="OpenLayers.js"></script> 

        <script> 

            function runVIEWER() { 

                function mapEvent(event) { 
                    actCenter = theVIEWER.getCenter(); 
                    actZoom = theVIEWER.getZoom(); 
                    if (sfeParms.cookies == "Y") { 
                        createCookie('GISDIF_CENTER',actCenter ,5) ; 
                        createCookie('GISDIF_ZOOM',actZoom ,5) ; 
                    } 
                } 

                function mapBaseLayerChanged(event) { 
                    if (sfeParms.cookies == "Y") { 
                        createCookie('GISDIF_BASE',event.layer.name ,5) ; 
                        createCookie('GISDIF_CENTER',actCenter ,5) ; 
                        createCookie('GISDIF_ZOOM',actZoom ,5) ; 
                    } 
                } 
    
                function createCookie(name,value,days) { 
                    if (days) { 
                        var date = new Date(); 
                        date.setTime(date.getTime()+(days*24*60*60*1000)); 
                        var expires = "; expires="+date.toGMTString(); 
                    } 
                    else var expires = ""; 
                    document.cookie = name+"="+value+expires+"; path=/"; 
                } 

                OpenLayers.ProxyHost = '/proxy/?url='; 
                if (document.location.protocol != "file:") { 
                    theParms = OpenLayers.Util.getArgs(); 
                } 
                else { 
                    theParms = {}; 
                    theParms.center = "0,0"; 
                    theParms.zoom = "0";             
                    theParms.blayer = "RoadUP"; 
                    theParms.data = "textfile.txt"; 
                    theParms.controls = 'panzoom,mouse'; 
                    theParms.layers = "RoadUP"; 
                    theParms.cookies = "Y"; 
                } 

                var sfeParms = {}; 
                var actCenter ; 
                var actZoom ; 
                var actLat ; 
                var actLon ; 
                var DEFAULT_LAT = 0; 
                var DEFAULT_LON = 0; 
                var DEFAULT_ZOOM_LEVEL = 0; 
                var DEFAULT_CONTROLS = ['panzoom','mouse']; 
                var DEFAULT_LAYERS = ['roadup']; 
                var IDX_LAT = 0; 
                var IDX_LON = 1; 

                sfeParms.centerLat = theParms.center ? 
                  parseFloat(theParms.center.split(",")[IDX_LAT]) :
DEFAULT_LAT; 
                sfeParms.centerLon = theParms.center ? 
                  parseFloat(theParms.center.split(",")[IDX_LON]) :
DEFAULT_LON; 
                sfeParms.zoom = theParms.zoom ? parseInt(theParms.zoom) :
DEFAULT_ZOOM_LEVEL; 
                sfeParms.controls = theParms.controls ? 
                  theParms.controls.split(",") : DEFAULT_CONTROLS; 
                sfeParms.layers = theParms.layers ? 
                  theParms.layers.split(",") : DEFAULT_LAYERS; 
                sfeParms.blayer = theParms.blayer; // ? theParms.blayer :
DEFAULT_LAYERS; 
                sfeParms.cookies = theParms.cookies; 
                sfeParms.data = theParms.data; // TODO: Make this "safe". 
                sfeParms.marker = theParms.marker; // TODO: Make this
"safe". 
    
                var theVIEWER = new OpenLayers.Map('map', { 
                  controls: [], maxResolution: 'auto', 
                  eventListeners: { 
                    "moveend": mapEvent, 
                    "zoomend": mapEvent, 
                    "changebaselayer": mapBaseLayerChanged 
                  } 
                }); 

                for(var i = 0; i < sfeParms.controls.length; i++) { 
                    switch(sfeParms.controls[i]) { 
                        case 'panzoombar': 
                          theVIEWER.addControl(new
OpenLayers.Control.PanZoomBar()); 
                        break; 
                        case 'panzoom': 
                          theVIEWER.addControl(new
OpenLayers.Control.PanZoom()); 
                        break; 
                        case 'layerswitcher': 
                            theVIEWER.addControl(new
OpenLayers.Control.LayerSwitcher()); 
                        break; 
                        case 'mouse': 
                            theVIEWER.addControl(new
OpenLayers.Control.MouseDefaults()); 
                        break; 
                        case 'overview': 
                            theVIEWER.addControl(new
OpenLayers.Control.OverviewMap()); 
                        break; 
                        case 'position': 
                            theVIEWER.addControl(new
OpenLayers.Control.MousePosition()); 
                        break; 
                    } 
                } 

                for(var i = 0; i < sfeParms.layers.length; i++) { 
                    switch(sfeParms.layers[i]) { 
                        case 'roadup': 
                            var Roadup = new OpenLayers.Layer.WMS( "RoadUP",

                              "http://localhost:8080/geoserver/wms", 
                              {layers: 'TM_Mvdeo'}, {singleTile: true }); 
                            theVIEWER.addLayer(Roadup) ; 
                        break; 
                        case 'gmaps': 
                            var GoogleStr = new OpenLayers.Layer.Google(
"Google Rutas y calles" ); 
                            var GoogleSat = new OpenLayers.Layer.Google(
"Google Satelite" , {type: G_SATELLITE_MAP }); 
                            var GooglePhy = new OpenLayers.Layer.Google(
"Google Fisico" , {type: G_PHYSICAL_MAP }); 
                            var GoogleHyb = new OpenLayers.Layer.Google(
"Google Mixto" , {type: G_HYBRID_MAP }); 
                            theVIEWER.addLayer(GoogleStr) ; 
                            theVIEWER.addLayer(GoogleSat) ; 
                            theVIEWER.addLayer(GooglePhy) ; 
                            theVIEWER.addLayer(GoogleHyb) ; 
                        break; 
                    } 
                } 

                switch(sfeParms.blayer) { 
                    case 'RoadUP': 
                        theVIEWER.setBaseLayer(Roadup); 
                    break; 
                   case 'Google Rutas y calles': 
                       theVIEWER.setBaseLayer(GoogleStr); 
                   break; 
                   case 'Google Satelite': 
                       theVIEWER.setBaseLayer(GoogleSat); 
                   break; 
                   case 'Google Fisico': 
                       theVIEWER.setBaseLayer(GooglePhy); 
                   break; 
                   case 'Google Mixto': 
                       theVIEWER.setBaseLayer(GoogleHyb); 
                   break; 
                } 

                theVIEWER.setCenter(new
OpenLayers.LonLat(sfeParms.centerLon, sfeParms.centerLat), sfeParms.zoom); 

                if (sfeParms.marker) { 
                    var m = new OpenLayers.Layer.Markers("Marker"); 
                    m.addMarker(new OpenLayers.Marker(new
OpenLayers.LonLat(sfeParms.centerLon, sfeParms.centerLat))); 
                    theVIEWER.addLayer(m); 
                } 
                if (sfeParms.data) { 
               var datalayer= new OpenLayers.Layer.Text("Movil", {location:
sfeParms.data }); 
             theVIEWER.addLayer(datalayer); 
                } 
           } 
    </script> 
</head> 

<body style="margin:0px;" onload="runVIEWER();"> 
    <div id="map" 
        style="width: 100%; height: 100%; background: lightyellow;"> 
    </div> 
</body> 

</html> 

The fact is that when I maximize the IE7 browser windows and change the base
layer, the new map automatically moves his center (x,y) downward and toward
the right as it was panned in that direction. 

It seems that all the maps must be reloaded. 

regards, 
  Leonel 

-----Mensaje original-----
De: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] En
nombre de Eric Lemoine
Enviado el: Domingo, 29 de Junio de 2008 06:26 a.m.
Para: leonel.rocha at altasur.com.uy; users at openlayers.org
Asunto: Re: [OpenLayers-Users] RV: IE7 screen resizing and map center....


Please provide a test case where this happens. It is hard to help you out
with so little information. Cheers. Eric

2008/6/26, leorochadecastro at gmail.com <leorochadecastro at gmail.com>:
> Hello, this is my first app with openlayers. I've 4 layers and this
> function: "map.setCenter(new OpenLayers.LonLat(actLon, actLat), 
> actZoom);" is working fine. But when I change size of the browser 
> window and select other base layer, it seems that the center moves 
> downwards and to the right.
>
> How can I fix this problem?
>
>
> LEONEL ROCHA
>  ALTASUR S.A.
>
>
>
_______________________________________________
Users mailing list
Users at openlayers.org http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list