2

I'm using MS4W on my local server.

This are some codes inside my mymap.map file.

MAP
    etc.....

    OUTPUTFORMAT
        NAME pnggd
        DRIVER "GD/PNG"
        MIMETYPE "image/png"
        IMAGEMODE PC256
        EXTENSION "png"
    END
    OUTPUTFORMAT
        NAME pnggd24
        DRIVER "GD/PNG"
        MIMETYPE "image/png"
        IMAGEMODE RGBA
        EXTENSION "png"
    END
    OUTPUTFORMAT
        NAME AGG
        DRIVER "AGG/PNG"
        IMAGEMODE RGB
    END
    OUTPUTFORMAT
        NAME AGGA
        DRIVER "AGG/PNG"
        IMAGEMODE RGBA
    END

    etc....

and this is my code for my PNG file location to be called.

LAYER 
    NAME "map1"
    STATUS DEFAULT
    TYPE RASTER
    DATA "/ms4w/Apache/htdocs/my_map/my_map_image/map1.png"
END

Here is my explorer.js file and some codes inside the file:

var view_map1 = new OpenLayers.Layer.WMS(
    "map1 overlay", "http://localhost/cgi-bin/mapserv.exe?map=c://ms4w/Apache/htdocs/my_map/mymap.map&LAYERS=map1&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&FORMAT=image/png", 
     {
         layers: 'map1',
         format: 'image/png'
     },{
        'ratio':1,
        singleTile: false,
        maxExtent: my_extent,
        isBaseLayer: false
      })
 map.addLayer(view_map1);

Is my code inside the .map file and .js file correct? or it should be not like that when to declare the OpenLayers and also for the shapefile.

Can anyone spare me some ideas and suggestions?

3
  • I don't use mapserver, but I think it extremely unlikely that the path to the images includes the location to the executable itself. Usually, web servers expose some virtual directory that maps to localhost. Commented Dec 8, 2014 at 12:07
  • @JohnBarça most of the sample code written and shared around internet world are goes like that. i think not much the problem there right? or what about the way i declare the openlayers.layers.wms is right and correct for png file to be called? and also to the .map file?
    – blinddevil
    Commented Dec 9, 2014 at 2:21
  • you mention a shapefile but your map file doesn't reference one. Is your data in a shapfile? if so the DATA should point to it, and TYPE should be polygon or line or point...
    – nmtoken
    Commented Mar 28, 2016 at 11:08

1 Answer 1

1

does my code inside the .map file and .js file correct?

The code in your map file does not look correct, because you say

or it should be not like that when to declare the openlayer and also for the shapefile.

I can't see any place in the map file where you declare the shapefile as the data source.

So instead of:

 LAYER 
    NAME "map1"
    STATUS DEFAULT
    TYPE RASTER
    DATA "/ms4w/Apache/htdocs/my_map/my_map_image/map1.png"
 END

You should have something like:

LAYER
    NAME "my map layer"
    TYPE POLYGON
    STATUS ON
    DATA "name-of-your-shapefile"
END

It appears you are confusing the job of the WMS, it converts data such as a shapefile into an image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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