Quantcast
Channel: Forum SIG - Systèmes d'Information Géographique et Géomatique
Viewing all articles
Browse latest Browse all 8030

[OpenLayers] Problème d'affichage de la carte dans le navigateur

$
0
0
bonjours a tous,

j'ai besoins d'afficher une carte avec deux couche dans un site web

pour cela j'ai utilisé open layers j'utilise mapserver en tant que serveur wms pour servir mes couches

voici mon map file:

Code:

MAP


NAME ROUTIER_WMS_SERVER
STATUS ON
SIZE 1000 500
SYMBOLSET ../etc/symbols.txt
EXTENT  503638.78 4064938.50  507620.53 4066415.00
UNITS METERS
SHAPEPATH "../data"
#IMAGECOLOR 0 0 0
IMAGETYPE png
FONTSET ../etc/fonts.txt


#
# Definition de l'interface web
#
WEB


    IMAGEPATH "C:/ms4w/tmp/ms_tmp/"
    IMAGEURL "/ms_tmp/"
    METADATA
        "wms_title"  "Routier WMS Server"
        "wms_onlineresource" "http://127.0.0.1/cgi-bin/mapserv.exe?MAP=C:/ms4w/htdocs/test.map"
        "wms_srs"  "EPSG:32631"
        "wms_enable_request" "*"
        ##"wms_feature_info_mime_type" "text/html"
        ##"wms_abstract"  ""
    END
END


PROJECTION
  "init=epsg:32631"
END
#
#Definition des couches
#
LAYER
  NAME Global
  METADATA
    "wms_title" "Globale"
  END
  TYPE RASTER
  STATUS ON
  DATA globale2.tif
  PROJECTION
    "init=epsg:32631"
  END
END


LAYER
    NAME troncon
    METADATA
        "wms_title" "Routier"
    END
    PROJECTION
        "init=epsg:32631"
    END
    STATUS ON
    TYPE LINE
    CONNECTIONTYPE POSTGIS
    CONNECTION "host=127.0.0.1 port=5432 dbname=reseauRoutier user=postgres password=asma1711"
    DATA "the_geom from troncon"
    CLASS
        NAME "Routier"
        STYLE
            COLOR 0 250 0
        END
    END   
END #LAYER


LAYER
    NAME Node
    METADATA
        "wms_title" "noeud"
    END
    PROJECTION
        "init=epsg:32631"
    END
    STATUS ON
    TYPE POINT
    CONNECTIONTYPE POSTGIS
    CONNECTION "host=127.0.0.1 port=5432 dbname=reseauRoutier user=postgres password=asma1711"
    DATA "the_geom from noeuds"
    CLASS
        NAME "noeud"
        STYLE
            SYMBOL 7
            SIZE 3
            COLOR 0 0 220
        END
    END   
END #LAYER
END #Mapfile

et voici mon fichier html:

Code:

<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='utf-8' />
    <title> Gestion du reseau routier</title>   
    <script type='text/javascript' src='OpenLayers.js'></script>
    <script type='text/javascript'>


    var map;
   
    function init() {
        var navigation_control = new OpenLayers.Control.Navigation({});
        var controls_array = [
            navigation_control,
            new OpenLayers.Control.PanZoomBar({}),
            new OpenLayers.Control.LayerSwitcher({}),
            new OpenLayers.Control.Permalink(),
            new OpenLayers.Control.MousePosition({})
        ];
        // Setup our map object
        map = new OpenLayers.Map('map_element', {
                                  controls: controls_array
                                });
       
        // Setup our two layer objects
        var wms_layer_map = new OpenLayers.Layer.WMS(
            'Base layer',
            'http://127.0.0.1/cgi-bin/mapserv.exe?map=C:\ms4w\htdocs\test.map&',
            {layers: 'Global'},
            {isBaseLayer: true}
        );


        // Add an overlay layer.  We set the transparent property to true
        //    in the WMS parameters so it doesn't cover up the base layer
        var wms_layer_labels = new OpenLayers.Layer.WMS(
            'Reseau Routier',
            'http://127.0.0.1/cgi-bin/mapserv.exe?map=C:\ms4w\htdocs\test.map&',
            {layers: 'Troncon,Node',
            visibility: false, transparent: true},
            {opacity: .5}
        );
       
        // Add layers to the map
        map.addLayers([wms_layer_map, wms_layer_labels]);
       
        //Add a control to the map
        map.addControl(new OpenLayers.Control.ScaleLine());
        //Create a overview map control
        var overview_map = new OpenLayers.Control.OverviewMap();
        // Zoom the map to the max extent
          map.addControls([
            overview_map,
            new OpenLayers.Control.KeyboardDefaults()
        ]);
        if(!map.getCenter()){
        map.zoomToMaxExtent();
        }
       
  }


    </script>
</head>


<body onload='init();'>
    <div id='map_element' style='width: 500px; height: 500px;'>
    </div>
</body>
</html>

quand je test mon serveur wms avec getcapabilities rien ne se passe mais avec get map ma carte s'affiche ainsi que les autres couches
mais quand je passe a open layers rien ne s'affiche c'est just une image blanche si quelqu'un pourrait détecter mon erreur

mon dead line approche et j'arrive pas afficher ma carte j'espere trouver une aide rapidement merci d'avance!

Viewing all articles
Browse latest Browse all 8030

Trending Articles