Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site. Si vous continuez à utiliser ce dernier, nous considèrerons que vous acceptez l'utilisation des cookies. J'ai compris ! ou En savoir plus !.
banniere

Le portail francophone de la géomatique


Toujours pas inscrit ? Mot de passe oublié ?
Nom d'utilisateur    Mot de passe              Toujours pas inscrit ?   Mot de passe oublié ?

Annonce

Rencontres QGIS 2025

L'appel à participation est ouvert jusqu'au 19 janvier 2025!

#1 Wed 06 January 2010 12:19

nicolas.leclerc
Participant actif
Date d'inscription: 8 Apr 2009
Messages: 78

openlayers et niveaux de zoom

Bonjour à tous,

J'essaye desesperement d'afficher mes cartes en fonctiondes niveaux de zoom avec openlayers mais sans succès, quelqu'un aurait t'il une idée ??

merci d'avance !

mon mapfile

Code:

MAP
   NAME "tutorial"
   SIZE 1020 500
   EXTENT 397718.645855151000000 172890.240151574000000    503353.752958698000000 237779.432429958000000
   UNITS METERS
   IMAGECOLOR 255 255 255
   
OUTPUTFORMAT
  NAME aggpng24
  DRIVER AGG/PNG
  MIMETYPE "image/png"
  IMAGEMODE RGB
  EXTENSION "png"
END


WEB
IMAGEPATH "C:/ms4w/Apache/htdocs/nl/tmp"
IMAGEURL "tmp/"
TEMPLATE "C:/ms4w/Apache/htdocs/nl/test6.php"
METADATA
    "wms_title"            "WMS"
    "wms_onlineresource"   "http://127.0.0.1/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/htdocs/nl/test4.map"   
    "wms_srs"              "EPSG:27561" 
              

END # Metadata
END

PROJECTION 
     "init=epsg:27561"
END

#Raster

LAYER
        NAME "m_500_estuaire"
        STATUS ON
        TYPE RASTER
        DATA "C:/ms4w/Apache/htdocs/nl/raster/m_500_estuaire.ecw"
        MAXSCALEDENOM 3000000
        MINSCALEDENOM 200000
        METADATA
           "wms_title"         "m_500_estuaire"
        END
        PROJECTION
           "init=epsg:27561"    # Lambert 1 Nord
        END
    END

LAYER
        NAME "m_100_ccih"
        STATUS ON
        TYPE RASTER
        DATA "C:/ms4w/Apache/htdocs/nl/raster/m_100_ccih.ecw"
        MAXSCALEDENOM 199999
        MINSCALEDENOM 35000
        METADATA
           "wms_title"         "m_100_ccih"
        END
        PROJECTION
           "init=epsg:27561"    # Lambert 1 Nord
        END
END

LAYER
        NAME "m_025_ccih"
        STATUS ON
        TYPE RASTER
        DATA "C:/ms4w/Apache/htdocs/nl/raster/m_025_ccih.ecw"
        MAXSCALEDENOM 34999
        MINSCALEDENOM 12000
        
        METADATA
           "wms_title"         "m_025_ccih"
        END
        PROJECTION
           "init=epsg:27561"    # Lambert 1 Nord
        END
END
    
LAYER
        NAME "m_010_codah_dense"
        STATUS ON
        TYPE RASTER
        DATA "C:/ms4w/Apache/htdocs/nl/raster/m_010_codah_dense.ecw"
        MAXSCALEDENOM 11999
        MINSCALEDENOM 3000
        METADATA
           "wms_title"         "m_010_codah_dense"
        END
        PROJECTION
           "init=epsg:27561"    # Lambert 1 Nord
        END
END

LAYER
        NAME "m_002_codah_dense"
        STATUS ON
        TYPE RASTER
        DATA "C:/ms4w/Apache/htdocs/nl/raster/m_002_codah_dense.ecw"
        MAXSCALEDENOM 2999
        MINSCALEDENOM 500
        
        METADATA
           "wms_title"         "m_002_codah_dense"
        END
        PROJECTION
           "init=epsg:27561"    # Lambert 1 Nord
        END
END

END # mapfile

Code:

<html>
    <head>
    <script src="./javascript/OpenLayers/OpenLayers.js" type="text/javascript"></script>
    <script type="text/javascript">

           var map;


            function init() {
                
                
               
               map= new OpenLayers.Map('map', 
               {maxExtent:new OpenLayers.Bounds(397718,172890,503353,237779),
                maxResolution: 'auto',
                units:'m',
                numZoomLevels: 11,
                scales: [1500000, 500000, 250000, 100000, 50000,
                      25000, 10000, 5000, 2000, 1000, 500],
                projection:'EPSG:27561'});

               var wms = new OpenLayers.Layer.WMS(
                    "m_500_estuaire",
                    "http://127.0.0.1/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/htdocs/nl/test4.map",
                    {layers: 'm_500_estuaire'}, {minScale: '200000'}, {maxScale: '3000000'}
                );

                var wms2 = new OpenLayers.Layer.WMS(
                    "m_100_ccih",
                    "http://127.0.0.1/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/htdocs/nl/test4.map",
                    {layers: 'm_100_ccih'}, {minScale: '35000'}, {maxScale: '199999'}
                    
                );
                
                var wms3 = new OpenLayers.Layer.WMS(
                    "m_025_ccih",
                    "http://127.0.0.1/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/htdocs/nl/test4.map",
                    {layers: 'm_025_ccih'}, {minScale: '12000'}, {maxScale: '34999'}
                    
                );
                
                var wms4 = new OpenLayers.Layer.WMS(
                    "m_010_codah_dense",
                    "http://127.0.0.1/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/htdocs/nl/test4.map",
                    {layers: 'm_010_codah_dense'}, {minScale: '11999'}, {maxScale: '3000'}
                );
                
                var wms5 = new OpenLayers.Layer.WMS(
                    "m_002_codah_dense",
                    "http://127.0.0.1/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/htdocs/nl/test4.map",
                    {layers: 'm_002_codah_dense'}, {minScale: '500'}, {maxScale: '2999'}
                );
                
                map.addLayers([wms, wms2, wms3, wms4, wms5]);

                
                var overview = new OpenLayers.Control.OverviewMap();
                map.addControl(overview);
        
               
                map.addControl(new OpenLayers.Control.ScaleLine({
                div: document.getElementById("scalebar")
                }));
          
                map.addControl(new OpenLayers.Control.LayerSwitcher());
                
                map.addControl(new OpenLayers.Control.MousePosition({
                div: document.getElementById("mouseposition")
                }));
                
                var panel = new OpenLayers.Control.Panel({
                div: document.getElementById("panel")
                });
                map.addControl(panel);

                var history = new OpenLayers.Control.NavigationHistory();
                map.addControl(history);
                panel.addControls([history.next, history.previous]);
                
                map.zoomToMaxExtent();
            
            }
                
        </script>
    </head>

    <body onload="init()">
        <div id="map"  style="width:100%; height: 80%"></div>
        <div id="mouseposition"></div>
        <div id="panel"></div>
        <div id="scalebar"></div>
    </body>
</html>

Hors ligne

 

Pied de page des forums

Powered by FluxBB