In my previous code, I am using OpenLayers WMS to load a raster data through MapServer. As you can see, the mapserv.exe calls a local map file to load the raster data. I just heard PHP_MapScript, since it can convert a map file into a map object.

Is that possible to use this converted map object directly in OpenLayers WMS? Since the object can be easily modified such as "styling".

localWMS = new OpenLayers.Layer.WMS( "Local WMS layers",
          {layers: 'polygon',transparent: true}, {isBaseLayer: false} );

Someone who is familiar with PHP_MapScript, I am willing to hear from you.

1 Answer 1


The answer is no.

Mapscript and the mapfile are executed on the server and they have nothing to do with the OpenLayers client-side JavaScript. What you are requesting with OpenLayers.Layer.WMS is a set of images and metadata and by the time these get to the browser there is not much you can manipulate. Mapscript can be useful if you need to do lots of dynamic or repetitive manipulations on the server side, before the image is generated.

  • Thanks. Is that mapscript something similar to openlayer since it has function $map = ms_newMapObj(""). All the tutorial are saying mapserver can publish a map directly using $map->draw() function. I am confused what kind of map it will draw or just an image file with url. And then show this image on website with src=url. Thank you.
    – Yu Guo
    Jun 19, 2013 at 22:23
  • $map->draw() will draw an image. You can save that image, print it or show it on a website as any other image... you know, a simple image, nothing more.
    – Decio
    Jun 20, 2013 at 6:13
  • Hi Decio, I post a new question regarding the mapfile. Could you have a look in your convenience. gis.stackexchange.com/questions/64284/…
    – Yu Guo
    Jun 24, 2013 at 13:43

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.