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

Printemps des cartes 2024

#1 Fri 16 March 2012 14:53

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

projet webmapping

Bonjour,

je suis toujours sur mon projet de webmapping, et j'avance, je recule, je stagne...
En ce moment je stagne alors je m'autorise à poster une requête dans le forum.

Ce que je voudrais faire:
La carte d'un cadastre, interactive, càd que lorsqu'on clique sur les bâtis ou les parcelles du cadastre on puisse voir dans une fenêtre les informations correspondant à cette couche (n°, superficie, photos), et qu'il y est les réglementaires zoom, échelle, et que le client puisse cocher les couches qu'il désire afficher ou non.

Ce que j'ai déjà:
-le cadastre numérisé sur arcgis
-le mapfile (généré à partir de qgis)
-j'ai créé des fichiers js et html mais je ne sais pas comment faire pour rendre la carte affichée interactive, comment faire appel à mes données?

code MAP:

Code:

# Map file created from QGIS project file C:/ms4w/apps/tutorial/htdocs/EXPORT.qgs
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
  NAME "QGIS-MAP"
  # Map image size
  SIZE 1000 700
  UNITS meters
  SHAPEPATH "/FOFIE/webmap"
  EXTENT 474019.898738 6459538.159607 476716.894323 6460851.927876
  
PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
END

  # Background color for the map canvas -- change as desired
  IMAGECOLOR    255 255 255
  IMAGEQUALITY  95
  IMAGETYPE     agg
  OUTPUTFORMAT
    NAME      agg
    DRIVER    AGG/PNG
    IMAGEMODE RGB
  END
  # Legend
LEGEND
    IMAGECOLOR 255 255 255
    STATUS     ON
    KEYSIZE    18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
END

  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH '/tmp/'

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '/tmp/'

    # WMS server settings
    METADATA
      'ows_title'           'QGIS-MAP'
      'ows_onlineresource'  'http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/tutorial/htdocs/EXPORT.map'
      'ows_srs'             'EPSG:4326'
    END

    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See MapServer documentation
    TEMPLATE 'fooOnlyForWMSGetFeatureInfo'
  END

LAYER
    NAME 'parcelles'
    TYPE POLYGON
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
    EXTENT 474019.898738 6459538.159607 476716.894323 6460851.927876
    DATA 'C:/SIG/SAINT_AULAYE/SOPHIE/SHP/parcelles.shp'
    METADATA 'ows_title' 'parcelles'
END
    
    STATUS OFF
    TRANSPARENCY 100
    
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
            
CLASS
    NAME 'parcelles' 
    STYLE
    WIDTH 0.91 
    OUTLINECOLOR 0 0 0
    COLOR 255 193 151
    END
   END
END

    LAYER
        NAME 'bati_autre'
        TYPE POLYGON
        DUMP true
        TEMPLATE fooOnlyForWMSGetFeatureInfo
    EXTENT 474019.898738 6459538.159607 476716.894323 6460851.927876
        DATA 'C:/SIG/SAINT_AULAYE/SOPHIE/SHP/bati_autre.shp'
        METADATA 'ows_title' 'bati_autre'
    END
   
    STATUS OFF
    TRANSPARENCY 61
    
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    
    CLASS
       NAME 'bati_autre' 
       STYLE
         WIDTH 0.91 
         OUTLINECOLOR 0 0 0
         COLOR 178 255 183
       END
    END
  END

    LAYER
        NAME 'bati_dur'
        TYPE POLYGON
        DUMP true
        TEMPLATE fooOnlyForWMSGetFeatureInfo
    EXTENT 474019.898738 6459538.159607 476716.894323 6460851.927876
        DATA 'C:/SIG/SAINT_AULAYE/SOPHIE/SHP/bati_dur.shp'
        METADATA 'ows_title' 'bati_dur'
    END
    
    STATUS OFF
    TRANSPARENCY 100
    
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    
    CLASS
        NAME 'bati_dur' 
        EXPRESSION 'Bati'
        STYLE
          WIDTH 0.91 
          OUTLINECOLOR 0 0 0
          COLOR 156 156 156
    END
    
    LABEL
        COLOR 132 31 31
        SHADOWCOLOR 218 218 218
        SHADOWSIZE 2 2 
        TYPE TRUETYPE
        FONT ARIAL
        SIZE 12 
        ANTIALIAS TRUE
        POSITION CL
        PARTIALS FALSE
        MINDISTANCE 300
        BUFFER
    END
    END
   END
  END

  LAYER
    NAME 'bati_public'
    TYPE POLYGON
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
  EXTENT 474019.898738 6459538.159607 476716.894323 6460851.927876
    DATA 'C:/SIG/SAINT_AULAYE/SOPHIE/SHP/bati_public.shp'
    METADATA 'ows_title' 'bati_public'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'bati_public' 
       STYLE
         WIDTH 0.91 
         OUTLINECOLOR 0 0 0
         COLOR 203 0 0
       END
    END
  END

  LAYER
    NAME 'bati_leger'
    TYPE POLYGON
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
  EXTENT 474019.898738 6459538.159607 476716.894323 6460851.927876
    DATA 'C:/SIG/SAINT_AULAYE/SOPHIE/SHP/bati_leger.shp'
    METADATA 'ows_title' 'bati_leger'
    END
    STATUS OFF
    TRANSPARENCY 45
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'bati_leger' 
       STYLE
         WIDTH 0.91 
         OUTLINECOLOR 0 0 0
         COLOR 203 181 51
       END
    END
  END

  LAYER
    NAME 'bordure_et_trottoir'
    TYPE LINE
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
  EXTENT 474019.898738 6459538.159607 476716.894323 6460851.927876
    DATA 'C:/SIG/SAINT_AULAYE/SOPHIE/SHP/bordure_et_trottoir.shp'
    METADATA 'ows_title' 'bordure_et_trottoir'
    END
    STATUS OFF
    TRANSPARENCY 100
    CLASS
       NAME 'bordure_et_trottoir' 
       STYLE
        COLOR 0 0 0
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
  END
END

Code JS :

Code:

var mapPanel;

function init() {

    var option = {
        projection: new OpenLayers.Projection("EPSG:4326"),
        units: "m",
        numZoomLevels: 18,
        maxExtent: new OpenLayers.Bounds (474019.898738, 6459538.159607,
                                          476716.894323, 6460851.927876)
        };

    var map = new OpenLayers.Map ('map', {
        projection: new OpenLayers.Projection("EPSG:4326"),
        units: "m",
        numZoomLevels: 18,
        maxExtent: new OpenLayers.Bounds (474019.898738, 6459538.159607,
                                          476716.894323, 6460851.927876),
        allOverlays: true,
        
        controls: [
            new OpenLayers.Control.MousePosition(),
            new OpenLayers.Control.LayerSwitcher(), 
            new OpenLayers.Control.PanZoomBar(),
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.ScaleLine()
            ]
            });
            
    var wms = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://labs.metacarta.com/wms/vmap0?", {layer: 'basic'});
        map.addLayer(layer_wms);
        
    com_layer = new OpenLayers.Layer.WMS("com_layer",
        "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/EXPORT.map&mode=map&layer=parcelles&layer=bati_autre&layer=bati_dur&layer=bati_public&layer=bati_leger&layer=bordure_et_trottoir",
        {layers: "com_layer", isBaseLayer: false}
    );
    map.addLayer(com_layer);
    map.zoomToMaxExtent();

//Toolbar
    var ctrl, toolbarItems = [], action, actions = {};
    
//ZoomToMaxExtent
    action = new GeoExt.Action ({
        control: new OpenLayers.Control.ZoomToMaxExtent(),
        map: map,
        text: "Emprise",
        tooltip: "Étendue maximale de la carte"
    });
    actions["max_extent"] = action;
    toolbarItems.push(action);
    toolbarItems.push("-");
    
//Navigation
    action = new GeoExt.Action({
        text: "Déplacement",
        control: new OpenLayers.Control.Navigation(),
        map: map,
        allowDepress: false,
        pressed: true,
        tooltip: "Se déplacer",
        checked: true
    });
    actions["nav"] = action;
    toolbarItems.push(action);
    
//Controle de navigation: retour/suivant
ctrl = new OpenLayers.Control.NavigationHistory();
    map.addControl(ctrl);

    action = new GeoExt.Action({
        text: "Retour",
        control: ctrl.previous,
        disabled: false,
        tooltip: "Vue précédente"
    });
    actions["previous"] = action;
    toolbarItems.push(action);

    action = new GeoExt.Action({
        text: "Suivant",
        control: ctrl.next,
        disabled: false,
        tooltip: "Vue suivante"
    });
    actions["next"] = action;
    toolbarItems.push(action);
    
  //Information
    action = new GeoExt.Action({
        text: "Information",
        control: new OpenLayers.Control.WMSGetFeatureInfo(),
        map: map,
        allowDepress: true,
        pressed: false,
        tooltip: "Information",    
    });
    actions["info"] = action;
    toolbarItems.push(action);
    toolbarItems.push();
    toolbarItems.push("->");

    info = new OpenLayers.Control.WMSGetFeatureInfo({
            url: 'http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/EXPORT.map&mode=map&layer=parcelles&layer=bati_autre&layer=bati_dur&layer=bati_public&layer=bati_leger&layer=bordure_et_trottoir&mode=map',
            title: 'Informations',
            queryVisible: true,
            eventListeners: {
                getFeatureInfo: function(event) {
                    //info bulle
                    map.addPopup(new OpenLayers.Popup.FramedCloud(
                        "INFO", 
                        map.getLonLatFromPixel(event.xy),
                        null,
                        "<h1>Info</h1>",
                        null,
                        true,
                        null
                    ));
                }
            }
        });
        map.addControl(info);
        info.activate();

//Menu déroulant
    toolbarItems.push({
        text: "Menu",
        menu: new Ext.menu.Menu({
            items: [
                // Emprise
                actions["max_extent"],
                // Navigation= Déplacement, permet de déplacer le fond de carte
                new Ext.menu.CheckItem(actions["nav"]),
                // Retour/Suivant
                actions["previous"],
                actions["next"],
                //Info
                actions["info"]
        
            ]
        })
    });
    
//Fenêtre d'affichage de la carte
   new Ext.Window({
        x      :450,
        y      :70,
        title  : "Fond cadastral de Saint-Aulaye",
        height : 400,
        width  : 600,
        layout : "fit",
        items  : [{
            xtype  : "gx_mappanel",
            id     : "mappanel",
            map    : map,
            center : [1.32385,47.77679],
            zoom   : 11,
            tbar   : toolbarItems,
        
            layers: [new OpenLayers.Layer.WMS(
                "OpenLayers WMS",
                "http://labs.metacarta.com/wms/vmap0",
                {layers: 'basic'}),
                new OpenLayers.Layer.Google ("Google Physical",{type: google.maps.MapTypeId.TERRAIN})]
            }],
    }).show();
    mapPanel = Ext.getCmp("mappanel");
        var proj = new OpenLayers.Projection("EPSG:4326");
        var posgps = new OpenLayers.LonLat(0.710, 47.473);    
    map.setCenter(posgps.transform(proj, map.getProjectionObject()))
};

Code HTML :

Code:

<html>
    <head>
        <title>Saint-Aulaye</title>
        
        <script src="http://www.openlayers.org/api/2.11/OpenLayers.js"></script>
        <script src="EXPORT.js"></script>
        <script type="javascript">
                var map;
            function init(){
                map = new OpenLayers.Map('map', {
                    controls: [
                        new OpenLayers.Control.Navigation(),
                        new OpenLayers.Control.PanZoomBar(),
                        new OpenLayers.Control.LayerSwitcher({'ascending':false}),
                        new OpenLayers.Control.Permalink(),
                        new OpenLayers.Control.ScaleLine(),
                        new OpenLayers.Control.Permalink('permalink'),
                        new OpenLayers.Control.MousePosition(),
                        new OpenLayers.Control.OverviewMap(),
                        new OpenLayers.Control.KeyboardDefaults()
                    ],
                    numZoomLevels: 6
                    
                });
        </script>
    </head>
    
    <body>
        <div>
            <p align= "center">
            <font size=8><font color=#03224C>Fond cadastral de la ville de Saint-Aulaye</font></font>
            </p>
        </div>
        <div>
            <img border="1" src="http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/EXPORT.map&mode=map&layer=parcelles&layer=bati_autre&layer=bati_dur&layer=bati_public&layer=bati_leger&layer=bordure_et_trottoir"/>
        </div>
    </body>
</html>

Voilà, dans le js j'avais repris le modèle d'un exercice que l'on avait fait en cours mais en utilisant des couches openlayers or je voudrais mettre mes propres données, éventuellement sur un fond de carte openlayers. Donc je pense que pour l'instant j'ai écris n'importe quoi!!!


Merci énormément pour votre aide

Cordialement

Iphi

Hors ligne

 

#2 Fri 16 March 2012 16:16

Tony VINCENT
Participant actif
Lieu: Poitiers
Date d'inscription: 13 Jan 2010
Messages: 86

Re: projet webmapping

Bonjour,

après avoir regardé un petit peu ton code (js), je vois que tu utilise des fonctions issu de ExtJS et Geoext.

Or dans ta page html, tu ne fais pas appel à ces librairies.
Et il y a d'autres petites erreurs de codage.


Je pense que pour commencer, utilise simplement OpenLayers. Et par la suite, implémenter ExtJS et Geoext si tu le souhaites.



Code:

<html>
    <head>
        <title>Saint-Aulaye</title>
        
        <script src="http://www.openlayers.org/api/2.11/OpenLayers.js"></script>
        <script type="javascript">
            var map;
            function init(){
                map = new OpenLayers.Map('map', {
                    controls: [
                        new OpenLayers.Control.Navigation(),
                        new OpenLayers.Control.PanZoomBar(),
                        new OpenLayers.Control.LayerSwitcher({'ascending':false}),
                        new OpenLayers.Control.Permalink(),
                        new OpenLayers.Control.ScaleLine(),
                        new OpenLayers.Control.MousePosition()
                    ],
                    numZoomLevels: 6
               });

              var wms = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://labs.metacarta.com/wms/vmap0?", {layer: 'basic'});
              map.addLayer(layer_wms);
        
    var com_layer = new OpenLayers.Layer.WMS("com_layer",
        "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/EXPORT.map&mode=map&layer=parcelles&layer=bati_autre&layer=bati_dur&layer=bati_public&layer=bati_leger&layer=bordure_et_trottoir",
        {layers: "com_layer", isBaseLayer: false}
    );
    map.addLayer(com_layer);

               map.zoomToMaxExtent();
            }
        </script>
    </head>
    
    <body onload="init()">>
        <div id="map" style="width:570px;height:570px;border:1px solid #bbb;"></div>       
    </body>
</html>

Essai ce code là, pour voir.


Tony

Hors ligne

 

#3 Mon 19 March 2012 16:30

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

Re: projet webmapping

Bonjour Tony,
merci de ta réponse, ça a fonctionné avec ton code.
Mais en fait j'ai encore modifié le code js en prenant mes couches séparément car l'idée est de pouvoir obtenir des informations en cliquant sur les entités. Sauf que maintenant il me dit que "init is not defined"...
Ce que j'ai à cet instant :

Code:

var map;

function init(){

    var option = {
        projection: new OpenLayers.Projection("EPSG:4326"),
        units: "m",
        numZoomLevels: 18,
        maxExtent: new OpenLayers.Bounds (474019.898738, 6459538.159607,
                                          476716.894323, 6460851.927876)
        };

    var map = new OpenLayers.Map ('map', {
        controls: [
            new OpenLayers.Control.MousePosition(),
            new OpenLayers.Control.LayerSwitcher(), 
            new OpenLayers.Control.PanZoomBar(),
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.ScaleLine()
            ],
            numZoomLevels: 18
            
        layers: [ 
            new OpenLayers.Layer.WMS("OpenLayers WMS",
            "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'}),
            new OpenLayers.Layer.Map("Parcelles",        "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/EXP_parcelles.map&mode=map&layers=parcelles"),
            new OpenLayers.Layer.Map("Bati_dur","http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/EXP_bati_dur.map&mode=map&layers=bati_dur"),
            new OpenLayers.Layer.Map("Bati_public","http://localhost/cgi-bin/mapserv.exe?map=C:/Users/H/Desktop/FOFIE/webmap/public.map"),
            new OpenLayers.Layer.Map("Bati_autre", "http://localhost/cgi-bin/mapserv.exe?map=C:/Users/H/Desktop/FOFIE/webmap/autre.map")]
                });
                
    map.addLayer(layers);
    map.zoomToMaxExtent(new OpenLayers.Bounds());
    map.addControl(controls);
                };

Merci.

Iphi

Hors ligne

 

#4 Mon 19 March 2012 21:10

Tony VINCENT
Participant actif
Lieu: Poitiers
Date d'inscription: 13 Jan 2010
Messages: 86

Re: projet webmapping

Bonsoir,

Est-ce que tu as séparer ton code javascript de ton code html ?
Si oui, as-tu bien fait appel à la page contenant le javascript.

C'est cette ligne qui appel la fonction init().

Code:

<body onload="init()">

Mais comme il ne la trouve pas, il te dit que la fonction n'est pas définit.


Il faut donc rajouter cette ligne sous l'appel d'OpenLayer.

Code:

<script src="[chemin_fichier]/[nom_du_fichier].js"></script>

Sinon, redonne nous ton code (HTML+Javascript), c'est plus facile pour voir les erreurs éventuelles.


Tony

Dernière modification par Tony VINCENT (Mon 19 March 2012 21:11)

Hors ligne

 

#5 Tue 20 March 2012 09:41

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

Re: projet webmapping

Bonjour,

mon code html est :

Code:

<html>

    <head>
        <title>Saint-Aulaye</title>
        
        <script src="C:\ms4w\apps\tutorial\htdocs\OpenLayers.js"></script>
        <script type="text/javascript" src="C:\ms4w\apps\tutorial\htdocs\EXPORT.js"></script>
    </head>
    
    <body onload="init()">
        <h1 id="title"><font color= "#03224C" size=20><center>Fond cadastral de Saint-Aulaye</center></font></h1>
        <div id="map" style="width:570px;height:570px;border:1px solid #bbb;"></div>
    </body>
    
</html>

et j'ai essayé aussi comme ça :

Code:

<html>

    <head>
        <title>Saint-Aulaye</title>
        
        <script src="/ms4w/apps/tutorial/htdocs/OpenLayers.js"></script>
        <script type="text/javascript" src="/ms4w/apps/tutorial/htdocs/EXPORT.js"></script>
    </head>
    
    <body onload="init()">
        <h1 id="title"><font color= "#03224C" size=20><center>Fond cadastral de Saint-Aulaye</center></font></h1>
        <div id="map" style="width:570px;height:570px;border:1px solid #bbb;"></div>
    </body>
    
</html>

Je n'ai pas changé le js du dessus pour l'instant.

Hors ligne

 

#6 Tue 20 March 2012 11:41

Tony VINCENT
Participant actif
Lieu: Poitiers
Date d'inscription: 13 Jan 2010
Messages: 86

Re: projet webmapping

Bonjour,

peux-tu mettre ton fichier EXPORT.js au même niveau que ton fichier HTML.

Et l'appeler avec ceci :

       

Code:

<script type="text/javascript" src="EXPORT.js"></script>

Normalement, il doit trouver la fonction init().


Tony

Hors ligne

 

#7 Tue 20 March 2012 16:35

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

Re: projet webmapping

Bonjour,
Maintenant je n'ai plus d'erreur, sauf que je n'arrive pas à afficher les couches dont j'ai besoin... et la carte OL WMS ne s'affiche pas dans la fenêtre où je voudrais tout! HELP, je craque

Code js :

Code:

var map;

function init(){

    var option = {
        projection: new OpenLayers.Projection("EPSG:4326"),
        units: "m",
        numZoomLevels: 18,
        maxExtent: new OpenLayers.Bounds (474019.898738, 6459538.159607,
                                          476716.894323, 6460851.927876)
        };

    var map = new OpenLayers.Map ('map', {
        controls: [
            new OpenLayers.Control.MousePosition(),
            new OpenLayers.Control.LayerSwitcher(), 
            new OpenLayers.Control.PanZoomBar(),
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.ScaleLine()
            ],
            numZoomLevels: 18
            });
            
    var map = new OpenLayers.Map ('map', {
        layers: [ 
            new OpenLayers.Layer.WMS("OpenLayers WMS",
            "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'}),
            new OpenLayers.Layer.WMS("Parcelles", "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/EXP_parcelles.map&mode=map&layers=parcelles"),
            new OpenLayers.Layer.WMS("Bati_dur","http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/EXP_bati_dur.map&mode=map&layers=bati_dur"),
            new OpenLayers.Layer.WMS("Bati_public","http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/EXP_public.map&mode=map&layers=bati_public"),
            new OpenLayers.Layer.WMS("Bati_autre", "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/EXP_autre.map&mode=map&layers=bati_autre")],
        center: new OpenLayers.LonLat(2, 47),
        zoom: 6
                });
                }

Code html :

Code:

<html>

    <head>
        <title>Saint-Aulaye</title>
        
        <script src="http://www.openlayers.org/api/2.11/OpenLayers.js"></script>
        <script type="text/javascript" src="EXPORT.js"></script>

    </head>
    
    <body onload='init();'>
        <div h1 id="title"><font color= "#03224C" size=20><center>Ville de Saint-Aulaye</center></font></h1></div>
        <div id="map" style="width:570px;height:570px;border:1px solid #bbb;"></div>
        
    </body>
    
</html>

Merci de votre aide
Bonne soirée

Iphi

Hors ligne

 

#8 Thu 22 March 2012 10:07

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

Re: projet webmapping

Bonjour,
après quelques recherches et conseils, il m'est apparu que je dois transformer mes couches en WMS dans le mapfile et les appeler ainsi dans le js, mais cela ne fonctionne pas, il me dit que "OpenLayers.WMS is not a constructor"

Voici le .map :

Code:

# Map file created from QGIS project file C:/ms4w/apps/tutorial/htdocs/parcelles.qgs
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
  NAME "QGIS-MAP"
  # Map image size
  SIZE 1000 1000
  UNITS meters

  EXTENT 474019.898738 6459538.159607 476716.894323 6460851.927876
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
  END

  # Background color for the map canvas -- change as desired
  IMAGECOLOR 255 255 255
  IMAGEQUALITY 95
  IMAGETYPE agg

  OUTPUTFORMAT
    NAME agg
    DRIVER AGG/PNG
    IMAGEMODE RGB
  END
  # Legend
  LEGEND
      IMAGECOLOR 255 255 255
    STATUS ON
    KEYSIZE 18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
  END

  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH '/tmp/'

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '/tmp/'

    # WMS server settings
    METADATA
      'wms_title'           'WMS Parcelles Server'
      'wms_onlineresource'  'http://localhost/cgi-bin/mapserv.exe?map=wms.map/Users/H/Desktop/FOFIE/webmap/parcelles.map'
      'wms_srs'             'EPSG:4326'
    END

    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See MapServer documentation
    TEMPLATE 'fooOnlyForWMSGetFeatureInfo'
  END

  LAYER
    NAME 'parcelles'
    TYPE POLYGON
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
  EXTENT 474019.898738 6459538.159607 476716.894323 6460851.927876
    DATA 'C:/SIG/SAINT_AULAYE/SOPHIE/SHP/parcelles.shp'
    METADATA
      'wms_title' 'parcelles'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    CONNECTIONTYPE WMS
    CONNECTION "http://localhost/cgi-bin/mapserv.exe?map=wms.map/Users/H/Desktop/FOFIE/webmap/parcelles.map"
    END
    CLASS
       NAME 'parcelles' 
       STYLE
         WIDTH 0.91 
         OUTLINECOLOR 0 0 0
         COLOR 255 193 151
       END
     LABEL 
      FONT arial
      TYPE truetype
      SIZE 8
      COLOR 0 0 0
      ANGLE 0
      POSITION cc
      FORCE true
      ANTIALIAS true
      PARTIALS true
     END 
    END
  END

END

Et le .js :

Code:

var map;
            
function init(){
    
    var option = {
            projection: new OpenLayers.Projection("EPSG:4326"),
            displayProjection: new OpenLayers.Projection ("EPSG:2154"),
            units: "m",
            numZoomLevels: 14,
            maxExtent: new OpenLayers.Bounds (474019.898738, 6459538.159607,
                                              476716.894323, 6460851.927876)
        };
    
    var map = new OpenLayers.Map ('map', {
        
        controls: [
            new OpenLayers.Control.MousePosition(),
            new OpenLayers.Control.LayerSwitcher(), 
            new OpenLayers.Control.PanZoomBar(),
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.ScaleLine()
            ],
            numZoomLevels: 14,
            });
        
        layers: [
            new OpenLayers.Layer.WMS("OpenLayers WMS", 
            "http://vmap0.tiles.osgeo.org/wms/vmap0", 
            {layers: 'basic'},    
            {center: new OpenLayers.LonLat(2, 47)}),
            new OpenLayers.WMS ("Parcelles", "http://localhost/cgi-bin/mapserv.exe?map=parcelles.map&", {layers:"parcelles", "transparent": true}),
            new OpenLayers.WMS ("Bati Dur", "http://localhost/cgi-bin/mapserv.exe?map=bati_dur.map&",{layers:"bati_dur", "transparent": true}),
            new OpenLayers.WMS ("Public", "http://localhost/cgi-bin/mapserv.exe?map=public.map&", {layers:"public", "transparent": true}),
            new OpenLayers.WMS ("Autre", "http://localhost/cgi-bin/mapserv.exe?map=autre.map&", {layers:"autre", "transparent": true})]
            }

Merci de votre aide.

Cordialement

Iphi

Hors ligne

 

#9 Thu 22 March 2012 10:46

Yves
Membre du bureau
Lieu: Aix-les-Bains
Date d'inscription: 22 Mar 2006
Messages: 9855
Site web

Re: projet webmapping

Iphi,

Il y a une typo dans les constructeurs de tes couches : OpenLayers.WMS n'existe pas, ce que dit très clairement le message, vérifie en regardant la première couche qui est correcte.

Y.


Yves Jacolin, bénévole de l'association GeoRezo.net, agit au nom et pour le compte de l'association - Partageons ce qui nous départage !!  - GeoRezo vous aide ? Aidez GeoRezo !

Hors ligne

 

#10 Thu 22 March 2012 11:11

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

Re: projet webmapping

Mais oui! Merci, je suis tellement dedans que je ne vois plus l'évident!
Merci pour tes yeux Yves.

Hors ligne

 

#11 Thu 22 March 2012 12:56

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

Re: projet webmapping

C'est toujours moi mais ça ne fonctionne pas et là je ne vois pas pourquoi! Il me redit 'init is not defined' et franchement je ne comprends pas.
Voici mon Code javascript :

Code:

var map;
        var lon = 2;
        var lat = 47;
        var zoom = 10;
            
function init(){
    
    var option = {
            projection: new OpenLayers.Projection("EPSG:4326"),
            units: "m",
            numZoomLevels: 14,
            maxExtent: new OpenLayers.Bounds (474019.898738, 6459538.159607,
                                              476716.894323, 6460851.927876)
        };
    
    
    var ol_wms = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", 
        {layers: 'basic'});
            
    var map = new OpenLayers.Map ('map', {
        controls: [
            new OpenLayers.Control.MousePosition(),
            new OpenLayers.Control.LayerSwitcher(), 
            new OpenLayers.Control.PanZoomBar(),
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.ScaleLine()
            ],
            numZoomLevels: 14};
    
            new OpenLayers.Layer.WMS ("Parcelles", "http://localhost/cgi-bin/mapserv.exe?map=EXP_parcelles.map&", {layers:"parcelles", "transparent": true}),
            new OpenLayers.Layer.WMS ("Bati Dur", "http://localhost/cgi-bin/mapserv.exe?map=EXP_bati_dur.map&",{layers:"bati_dur", "transparent": true}),
            new OpenLayers.Layer.WMS ("Public", "http://localhost/cgi-bin/mapserv.exe?map=EXP_public.map&", {layers:"public", "transparent": true}),
            new OpenLayers.Layer.WMS ("Autre", "http://localhost/cgi-bin/mapserv.exe?map=EXP_autre.map&", {layers:"autre", "transparent": true})
            );
        
        
            }

code Html :

Code:

<html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Saint-Aulaye</title>
        
        <script src="http://www.openlayers.org/api/2.11/OpenLayers.js"></script>
        <script type="text/javascript" src="EXPORT.js"></script>

    </head>
    
    <body onload='init();'>
        <h1 id="title"><font color= "#03224C" size=20><center>Ville de Saint-Aulaye</center></font></h1>
        <div id="map" style="width:570px;height:570px;border:1px solid #bbb;"></div>
        
    </body>
    
</html>

Merci de votre aide parce que je fatigue de stagner depuis des jours.

Cordialement

Iphi

Hors ligne

 

#12 Thu 22 March 2012 13:24

Yves
Membre du bureau
Lieu: Aix-les-Bains
Date d'inscription: 22 Mar 2006
Messages: 9855
Site web

Re: projet webmapping

Bonjour,

Utilises tu Firebug ? Es tu sous Firefox ?

J'ai cette erreur :

missing ) after argument list
numZoomLevels: 14};

OpenLayers.js (line 126, col 42)
   
init is not defined
init();


qui indique que tu as mis un ; au lieu de , après "numZoomLevels: 14};"

Y.


Yves Jacolin, bénévole de l'association GeoRezo.net, agit au nom et pour le compte de l'association - Partageons ce qui nous départage !!  - GeoRezo vous aide ? Aidez GeoRezo !

Hors ligne

 

#13 Thu 22 March 2012 13:31

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

Re: projet webmapping

Bonjour,

Oui j'ai la même erreur,
après correction je n'ai plus d'erreur indiquée dans firebug mais je n'ai toujours pas de carte non plus sad

Est ce que tu vois un mauvais appel de couches dans mon fichier javascript?

Merci

Iphi

Hors ligne

 

#14 Thu 22 March 2012 14:18

Yves
Membre du bureau
Lieu: Aix-les-Bains
Date d'inscription: 22 Mar 2006
Messages: 9855
Site web

Re: projet webmapping

oui ta couche ol_wms n'est pas chargée

map.addLayers([ol_wms]);


et tu ne centres pas la carte sur ton maxextent :

map.zoomToMaxExtent();


Y.


Yves Jacolin, bénévole de l'association GeoRezo.net, agit au nom et pour le compte de l'association - Partageons ce qui nous départage !!  - GeoRezo vous aide ? Aidez GeoRezo !

Hors ligne

 

#15 Fri 23 March 2012 09:42

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

Re: projet webmapping

Bonjour,

Quelques problèmes sont résolus, d'autres restent à résoudre.
Aujourd'hui, je souhaiterais solutionner celui de l'affichage de mes cartes. En effet elles s'affichent mais se superposent, masquant les couches précédentes et le fond de carte. Et lorsque je zoome, au lieu de m'agrandir les cartes, elles se multiplient. C'est un soucis de projection et de coordonnées mais je ne sais pas comment le résoudre.

Voici mon code .map :

Code:

# Map file created from QGIS project file C:/ms4w/apps/tutorial/htdocs/parcelles.qgs
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
  NAME "QGIS-MAP"
  # Map image size
  SIZE 1000 1000
  UNITS meters

  EXTENT 474020.891010 6459544.113240 476717.886595 6460857.881509
  FONTSET './fonts/fonts.list'
 
  PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
  END

  # Background color for the map canvas -- change as desired
  IMAGECOLOR 255 255 255
  IMAGEQUALITY 95
  IMAGETYPE agg

  OUTPUTFORMAT
    NAME agg
    DRIVER AGG/PNG
    IMAGEMODE RGB
  END
  # Legend
  LEGEND
      IMAGECOLOR 255 255 255
    STATUS ON
    KEYSIZE 18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
  END

  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH '/tmp/'

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '/tmp/'

    # WMS server settings
    METADATA
      'ows_title'           'QGIS-MAP'
      'ows_onlineresource'  'http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/tutorial/htdocs/EXP_parcelles.map'
      'ows_srs'             'EPSG:4326'
    END

    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See MapServer documentation
    TEMPLATE 'fooOnlyForWMSGetFeatureInfo'
  END

  LAYER
    NAME 'parcelles'
    TYPE POLYGON
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
  EXTENT 474020.891010 6459544.113240 476717.886595 6460857.881509
    DATA 'C:/SIG/SAINT_AULAYE/SOPHIE/SHP/parcelles.shp'
    METADATA
      'ows_title' 'parcelles'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    LABELITEM 'SIG_JOINT'
    CLASS
       NAME 'parcelles' 
       STYLE
         WIDTH 0.91 
         OUTLINECOLOR 0 0 0
         COLOR 255 193 151
       END
     LABEL 
      FONT arial
      TYPE truetype
      SIZE 9
      COLOR 0 0 0
      ANGLE 0
      POSITION cc
      FORCE true
      ANTIALIAS true
      PARTIALS true
     END 
    END
  END

END

Je ne mets qu'un seul exemple

le code .js :

Code:

var map;
                    
function init(){
    
    var option = {
            projection: new OpenLayers.Projection("EPSG:4326"),
            units: "m",
            numZoomLevels: 14,
            maxExtent: new OpenLayers.Bounds (474020.891010, 6459544.113240,                                   476717.886595, 6460857.881509)
        };
        
    var ol_wms = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", 
        {layers: 'basic'});
            
    var map = new OpenLayers.Map ('map', {
        controls: [
            new OpenLayers.Control.MousePosition(),
            new OpenLayers.Control.LayerSwitcher(), 
            new OpenLayers.Control.PanZoomBar(),
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.ScaleLine()
            ],
            numZoomLevels: 14});
            
    var parcelles =    new OpenLayers.Layer.WMS ("Parcelles", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_parcelles.map&LAYERS=ALL&MODE=MAP", {layers:"parcelles", "transparent": true});
    var bati = new OpenLayers.Layer.WMS ("Bati Dur", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_bati_dur.map&LAYERS=ALL&MODE=MAP",{layers:"bati_dur", "transparent": true});
    var bati_public = new OpenLayers.Layer.WMS ("Public", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_public.map&LAYERS=ALL&MODE=MAP", {layers:"public", "transparent": true});
    var autre = new OpenLayers.Layer.WMS ("Autre", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_autre.map&LAYERS=ALL&MODE=MAP", {layers:"autre", "transparent": true});
    
    map.addLayers ([ol_wms, parcelles, bati, bati_public, autre]);
    map.setCenter(new OpenLayers.LonLat(2, 45), 6);
                    }

Et le html :

Code:

<html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Saint-Aulaye</title>
        
        <script src="http://www.openlayers.org/api/2.11/OpenLayers.js"></script>
        <script type="text/javascript" src="EXPORT.js"></script>

    </head>
    
    <body onload='init();'>
        <h1 id="title"><font color= "#03224C" size=20><center>Ville de Saint-Aulaye</center></font></h1>
        <div id="map" style="width:570px;height:570px;border:1px solid #bbb;"></div>
        
    </body>
    
</html>

Merci de votre aide

Cordialement

Iphi

Hors ligne

 

#16 Sun 25 March 2012 17:14

Yves
Membre du bureau
Lieu: Aix-les-Bains
Date d'inscription: 22 Mar 2006
Messages: 9855
Site web

Re: projet webmapping

Bonjour,

Le problème vient de là :

EXTENT 474020.891010 6459544.113240 476717.886595 6460857.881509

  PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
  END


Ton extent n'est pas en latlong WGS84.

Y.


Yves Jacolin, bénévole de l'association GeoRezo.net, agit au nom et pour le compte de l'association - Partageons ce qui nous départage !!  - GeoRezo vous aide ? Aidez GeoRezo !

Hors ligne

 

#17 Wed 28 March 2012 15:38

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

Re: projet webmapping

Bonjour,
je suis désolée mais je ne trouve pas la solution. Comment puis je faire? Dois je modifier l'extent? Et dans ce cas, comment je trouve les nouvelles coordonnées de mon étendue maximale?
Ou dois je changer la projection wgs84 en rgf93? J'ai essayé plein de façons différentes mais ça ne fonctionne jamais.
Merci d'avance
Cordialement
Iphi

Hors ligne

 

#18 Wed 04 April 2012 11:21

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

Re: projet webmapping

Bonjour,
je pense avoir réussi à changer la projection de la couche et dans le mapfile mais j'ai toujours le même soucis avec la multiplication de couche et qui ne se mets pas à sa place...

.map :

Code:

MAP
  NAME "QGIS-MAP"
  # Map image size
  SIZE 1000 1000
  UNITS meters

  EXTENT 473830.764829 6459522.653955 476468.926311 6460883.471615
  FONTSET './fonts/fonts.list'
 
  PROJECTION
    "init=epsg:2154"
    'no_defs'
  END

  # Background color for the map canvas -- change as desired
  IMAGECOLOR 255 255 255
  IMAGEQUALITY 95
  IMAGETYPE gif

  OUTPUTFORMAT
    NAME gif
    DRIVER 'GD/GIF'
    MIMETYPE 'image/gif'
    EXTENSION 'gif'
  END
  # Legend
  LEGEND
      IMAGECOLOR 255 255 255
    STATUS ON
    KEYSIZE 18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
  END

  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH '/tmp/'

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '/tmp/'

    # WMS server settings
    METADATA
      'wms_title'           'QGIS-MAP'
      'wms_onlineresource'  'http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/tutorial/htdocs/EXP_parcelles.map'
      'wms_srs'             'EPSG:4326 EPSG:2154'
    END

    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See MapServer documentation
    TEMPLATE 'fooOnlyForWMSGetFeatureInfo'
  END

  LAYER
    NAME 'parcelles'
    TYPE POLYGON
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
  EXTENT 473830.764829 6459522.653955 476468.926311 6460883.471615
    DATA 'C:/SIG/SAINT_AULAYE/SOPHIE/SHP/parcelles.shp'
      METADATA
      'wms_srs' 'EPSG:2154'
      'wms_title' 'parcelles'
    
    END
    STATUS ON
    TRANSPARENCY 100
    PROJECTION
    "init=epsg:2154"
    'no_defs'
    END
    LABELITEM 'SIG_joint'
    CLASS
       NAME 'parcelles' 
       STYLE
         WIDTH 0.91 
         OUTLINECOLOR 0 0 0
         COLOR 255 193 151
       END
     LABEL 
      FONT arial
      TYPE truetype
      SIZE 8
      COLOR 0 0 0
      ANGLE 0
      POSITION cc
      FORCE true
      ANTIALIAS true
      PARTIALS true
     END 
    END
  END
END

.js :


Code:

var map, info;
                    
function init(){
    
    var option = {
            projection: new OpenLayers.Projection("EPSG:2154"),
            units: "m",
            numZoomLevels: 14,
            maxExtent: new OpenLayers.Bounds ()
        };
        
    var ol_wms = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", 
        {layers: 'basic'});
            
    var map = new OpenLayers.Map ('map', {
        controls: [
            new OpenLayers.Control.MousePosition(),
            new OpenLayers.Control.LayerSwitcher(), 
            new OpenLayers.Control.PanZoomBar(),
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.ScaleLine()
            ],
            numZoomLevels: 14});
            
    var parcelles =    new OpenLayers.Layer.WMS ("Parcelles", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_parcelles.map&LAYERS=ALL&MODE=MAP", {layers:"parcelles", "transparent": true});
    var bati = new OpenLayers.Layer.WMS ("Bati Dur", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_bati_dur.map&LAYERS=ALL&MODE=MAP", {layers:"bati_dur", "transparent": false});
    var bati_public = new OpenLayers.Layer.WMS ("Public", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_public.map&LAYERS=ALL&MODE=MAP", {layers:"public", "transparent": false});
    var autre = new OpenLayers.Layer.WMS ("Autre", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_autre.map&LAYERS=ALL&MODE=MAP", {layers:"autre", "transparent": false});

    map.addLayers ([ol_wms, parcelles, bati, bati_public, autre]);
    map.setCenter(new OpenLayers.LonLat(2, 45), 6);
    
                    }

Je ne vois plus quoi faire.

Merci c'est vraiment important pour moi de réussir à faire ça.

Cordialement

Hors ligne

 

#19 Wed 04 April 2012 12:06

Delu
Participant actif
Lieu: Briançon
Date d'inscription: 29 Apr 2008
Messages: 76

Re: projet webmapping

Bonjour,
A partir du moment où tu as plusieurs projections (4326 et 2154), je pense qu'il te manque la librairie proj4js pour qu'openlayers puisse reprojeter ta couche parcelles en 2154 sur ta baselayer "ol_wms"qui doit être en 4326 je suppose. Cherche un peu avec google tu devrais trouver ça facilement.
Ensuite tu mets le rep proj4js à coté de celui d'openlayers puis dans proj4js/lib/defs tu crées au moins deux fichiers. Un nommé EPSG2154.js avec ce contenu :

Code:

Proj4js.defs["EPSG:2154"]="+title=RGF93 / Lambert-93 +proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ";

un autre nommé EPSG4326.js avec ceci :

Code:

Proj4js.defs["EPSG:4326"]= "+title=WGS 84 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";

ctrl + F5 et vois si ça change qq chose

Hors ligne

 

#20 Wed 04 April 2012 12:09

Delu
Participant actif
Lieu: Briançon
Date d'inscription: 29 Apr 2008
Messages: 76

Re: projet webmapping

oubli : il te faut aussi évidement charger le .js de proj4. en plus du chargement d'openlayers et autre éventuellement, charges :
..........tonchemin/proj4js/lib/proj4js.js

Hors ligne

 

#21 Wed 04 April 2012 13:23

Iphi
Participant occasionnel
Date d'inscription: 23 Feb 2012
Messages: 29

Re: projet webmapping

Merci Delu pour ton aide, malheureusement ça ne marche toujours pas.
J'ai fait un truc un peu barbare, je suis allée sur google earth, de manière à récupérer les min x, min y, max x, max y en wgs84, sauf que maintenant j'ai une carte toute blanche, mais je n'ai pas de message d'erreur...
Tous mes cheveux sont par terre...

Hors ligne

 

#22 Wed 04 April 2012 14:11

Delu
Participant actif
Lieu: Briançon
Date d'inscription: 29 Apr 2008
Messages: 76

Re: projet webmapping

Je vois qq soucis dans ton code :
déjà tu définis les options de ta map mais tu ne les utilises pas lors de sa création

Code:

var options = {...};
var map = new OpenLayers.Map('map',options);

Ensuite ton objet map a une projection en 2154 mais ta layer 'ol_wms' n'a pas de projection, donc par défaut OL va considérer qu'elle est aussi en 2154 ce qui n'est probablement pas le cas. Dans tous les cas il est plus propre de lui donner explicitement une projection.
Ensuite dans tes options de la map, tu définis

Code:

maxExtent: new OpenLayers.Bounds ()

sans donner de valeur  :???? Peut-être que ça se fait mais tu devrais mettre des bounds correspondant à ton secteur de travail.
puis en fin de code tu as :

Code:

map.setCenter(new OpenLayers.LonLat(2, 45), 6);

ces coordonnées sont en 4326.

Bref, il faut mettre ton code en cohérence au niveau des projections.
Je te conseille de mettre ta map en 4326, puis de procéder par étape.
faire afficher d'abord que ton fond ol_wms en commentant l'ajout des couches métier.
quand ça fonctionne, règle les extend, bounds et setCenter pour te centrer là où doivent s'afficher tes couches.
Ensuite seulement essaie d'afficher une couche puis les autres.

Enfin regarde le paramètre baseLayer et son fonctionnement dans la doc openlayers, je ne sais pas comment ça se passe si tu as plusieurs baseLayer en différentes projections mais il est écrit ceci : isBaseLayer    {Boolean} Default is true for WMS layer.
Je pense qu'il ne faut pas que tes couches métiers soit en baseLayer -> donc  isBaseLayer = false pour ces couches.

Hors ligne

 

#23 Wed 04 April 2012 14:59

Delu
Participant actif
Lieu: Briançon
Date d'inscription: 29 Apr 2008
Messages: 76

Re: projet webmapping

tests ça :

Code:

var map, info;
                    
function init(){
    
    var option = {
            projection: new OpenLayers.Projection("EPSG:4326"),
            units: "m",
            numZoomLevels: 14,
            maxExtent: new OpenLayers.Bounds(0,43,4,47),
            controls: [
            new OpenLayers.Control.MousePosition(),
            new OpenLayers.Control.LayerSwitcher(), 
            new OpenLayers.Control.PanZoomBar(),
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.ScaleLine()
            ]
        };
        
    var ol_wms = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", 
        {layers: 'basic'});
            
    var map = new OpenLayers.Map ('map',options);
            
    var parcelles = new OpenLayers.Layer.WMS ("Parcelles", 
        "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_parcelles.map&LAYERS=ALL&MODE=MAP", 
        {layers:"parcelles", "transparent": true, projection:'EPSG:2154'}, // vu que ton .map de maserver sert aussi du 4326 en wms, tu peux tester de tout mettre en 4326 : mapserver reprojetera
        {isBaseLayer: false}
    );
    var bati = new OpenLayers.Layer.WMS ("Bati Dur", 
        "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_bati_dur.map&LAYERS=ALL&MODE=MAP", 
        {layers:"bati_dur", "transparent": false, projection:'EPSG:2154'},
        {isBaseLayer: false}
    );
    var bati_public = new OpenLayers.Layer.WMS ("Public", 
        "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_public.map&LAYERS=ALL&MODE=MAP", 
        {layers:"public", "transparent": false, projection:'EPSG:2154'},
        {isBaseLayer: false}
    );
    var autre = new OpenLayers.Layer.WMS ("Autre", 
        "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_autre.map&LAYERS=ALL&MODE=MAP", 
        {layers:"autre", "transparent": false, projection:'EPSG:2154'},
        {isBaseLayer: false}
    );

    // map.addLayers ([ol_wms, parcelles, bati, bati_public, autre]);
    map.addLayers ([ol_wms]); // tester d'abord si ça ça fonctionne correctement
    // map.addLayers ([ol_wms, parcelles]); // puis tester ça en commentant la ligne ci-dessus
    map.setCenter(new OpenLayers.LonLat(2, 45), 6);
   
}

et ajoute les 2 projections dans chaque couche de te ton map file :

Code:

'wms_srs' 'EPSG:4326 EPSG:2154'
'wms_title' 'parcelles'

Hors ligne

 

Pied de page des forums

Powered by FluxBB