0

I have a problem when I add a OpenLayers.Layer.WMS, I get a picture of my map but I can't do zoom on it. I read a lot of questions here but nothing help me. My MapServer map file is:

MAP
 ##CONFIG "MS_ERRORFILE" "/ms4w/tmp/ms_error.txt"
 ##DEBUG 2
 ##CONFIG "CPL_DEBUG" "ON"
 NAME mapa2
 SIZE 1400 900
 IMAGETYPE png
 IMAGECOLOR 196 240 255
 EXTENT -16.1737 27.6847 -13.1254 29.4506
 SHAPEPATH "datos"
 FONTSET "C:/../fonts.txt"
 WEB 
      TEMPLATE "/../index.html"
      IMAGEPATH "/../ms_tmp/"
      IMAGEURL "/ms_tmp/"
      METADATA
         "WMS_TITLE" mapa2
         "WMS_SRS" "EPSG:4326 EPSG:4258"
         "WMS_ONLINERESOURCE" "../mapa2.map"
         "WMS_ENABLE_REQUEST" "*"
      END
 END
 PROJECTION
    "init=epsg:4258"
 END
 UNITS DD
 #FOTOS AEREAS
 LAYER
    NAME Foto1
    TILEINDEX indice.shp
    TILEITEM location
    DATA Foto1
    TYPE RASTER
    STATUS on
    OFFSITE 252 252 252 
    METADATA
        WMS_NAME "Foto1"
        WMS_FORMAT "IMAGE/PNG"
        WMS_SRS "EPSG:4258"
    END
 END
 LAYER
    NAME    "MUNICIPIO"
    STATUS  ON
    DATA    MUNICIPIO
    LABELITEM "NOM_MUNICI"
    METADATA
        "WMS_TITLE" MUNICIPIO
    END
    PROJECTION
        "init=epsg:4258"
    END
    TYPE POLYGON
    CLASS
        STYLE
            COLOR 254 226 197
            OUTLINECOLOR    255 0 0
        END
        LABEL 
            SIZE SMALL
            COLOR 0 0 0
            ALIGN CENTER
            REPEATDISTANCE 9
            POSITION CC
        END
    END
 END
END

And I try to add the layer:

wms = new OpenLayers.Layer.WMS(
  'Municipios', 
  "../mapa2.map&service=wms&mode=map&request=getcapabilities",  
  {layers:"MUNICIPIO"},{
   isBaseLayer:"true",
   srs: "EPSG:4258",
  format: 'image/png',
  visibility: "true",
  transparent: "true", 
  singleTile: true,
  ratio: 1 });

Anybody can help me?

  • 1
    I guess that mode=map can make troubles. It is either-or with WMS and mode=map. – user30184 Jun 17 '14 at 14:33
  • I have the same problem using only one of them. – user2898914 Jun 17 '14 at 14:36
  • Do you know that if your Mapserver is new enough it has OpenLayers as an outputformat? It creates a simple viewer when you use &format=application/openlayers and by looking at the source code you can see a working example. Try 188.64.1.61/cgi-bin/… – user30184 Jun 17 '14 at 15:49
  • OpenLayers is a library, I only call to the mapserver to request a wms. – user2898914 Jun 17 '14 at 15:58
  • Yes, but because it looks like you have used wrong code when trying to add Mapserver WMS into your application I suggested to have a look how it has been done in a working application. I do not master OpenLayers myself, I am sorry. – user30184 Jun 17 '14 at 16:02
1
wms = new OpenLayers.Layer.WMS(
  'Municipios',"../mapa2.map&service=wms&mode=map&request=getcapabilities",  

This line is incorrect. You need to use the service end point only so it should be something like:

wms = new OpenLayers.Layer.WMS(
  'Municipios',"http://yourservice/mapserv.exe?map=mapa2.map&",
0

You need to add the control OpenLayers.Control.Navigation() to the OpenLayers.Map object. Please check this: http://dev.openlayers.org/releases/OpenLayers-2.8/doc/apidocs/files/OpenLayers/Control-js.html Hope it helps if you haven´t found the solution already.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.