Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to render WMS MapServer data on top of Google Maps using the OpenLayers JS library. My problem arises when I try to render the data as a series of points throughout the New York City area. On my local machine I get a broken image, but on my live server I get no broken PNG data or anything at all.

Any help would be very much appreciated.

You can also check out the live site at:

OpenLayer JavaScript code below:

var map;
var mapBounds      = new OpenLayers.Bounds(-8266100.0, 4938263.9, -8204223.4, 4999860.8);
var movementBounds = new OpenLayers.Bounds(-8266100.0, 4938263.9, -8204223.4, 5030000.0);
var aliasproj = new OpenLayers.Projection("EPSG:4326");
var options = {
        projection: "EPSG:4326",
        units: "ft",
        maxResolution: 'auto',
        restrictedExtent: movementBounds,
        maxExtent: mapBounds

function init(){

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

    var base_layer = new OpenLayers.Layer.Google(
                    'Google Streets', // the default
                    {   numZoomLevels: 20, 
                        projection: aliasproj, 
                        isBaseLayer: true

    //change 'Oviedo12' to your login name
    var wms_layer = new OpenLayers.Layer.WMS("WMS Overlay",
        {layers: 'L_line', transparent: true, format: 'image/png', reqType:'wms'},
        {isBaseLayer: false, visibility: true}

    map.addLayers([base_layer, wms_layer])
    //map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
    map.addControl(new OpenLayers.Control.MousePosition({position: new OpenLayers.Pixel(0,0)}));

Map file code:

  STATUS         ON
  IMAGECOLOR     255 255 255  


      NAME 'circle'
      POINTS 1 1 END

    NAME png
    MIMETYPE "image/png"
    EXTENSION "png"

    NAME jpeg
    MIMETYPE "image/jpeg"
    EXTENSION "jpg"

END # All map files must come to an end just as all other things must come to...

PHP code for dynamic render:


if (!extension_loaded("MapScript")) dl("php_mapscript.so");

$request = ms_newowsrequestobj();

foreach ($_GET as $k=>$v) {
     $request->setParameter($k, $v);

$oMap = ms_newMapobj("../maps/dynamic.map");

$new_layer =ms_newlayerobj($oMap);
$new_layer->set("type", MS_LAYER_POINT);
$new_layer->set("dump", 1);
$new_layer->set("status", 1);
$new_class = ms_newClassObj($new_layer);
$new_style = ms_newStyleObj($new_class);
$new_style-> color->setRGB(0, 0,255);
$new_style->set("symbolname", "circle");
$new_style->set("size", 5);

$new_layer->set("connection","stuff to connect to db");
$data="the_geom from (select the_geom from station2 where lines = 'Canarsie') as foo using unique the_geom using SRID=4326";
echo ;
$new_layer->set("data",$data) ;

$contenttype = ms_iostripstdoutbuffercontenttype();
if ($contenttype == 'image/png')
   header('Content-type: image/png');
    $buffer = ms_iogetstdoutbufferstring();
    echo $buffer;
share|improve this question
It looks like MapServer can't open your map file. Warning: [MapServer Error]: msLoadMap(): First token must be MAP, this doesn't look like a mapfile. in /home/Oviedo12/public_html/final/subway crowding/mapscripts/dynamicwms.php on line 13 Warning: Failed to open map file ../maps/dynamic.map in /home/Oviedo12/public_html/final/subway crowding/mapscripts/dynamicwms.php on line 13 Fatal error: Object expected as argument. in /home/Oviedo12/public_html/final/subway crowding/mapscripts/dynamicwms.php on line 16 I would check permissions on that file. –  DavidF Dec 18 '12 at 21:24
I fixed that error and placed the correct mapfile file. –  user13653 Dec 18 '12 at 21:53
Your link to the live site doesn't work. –  Fezter Dec 18 '12 at 22:38
add comment

1 Answer 1

Check your ms_iostripstdoutbuffercontenttype() function, I think it's setting your $contenttype as text when it should be setting it as PNG. Also, Chrome is complaining that this link is 404'ing:

edit: Also as Dave points out in the comment, set your map to a static path instead of a dynamic one and see if that helps.

edit x2: Change your $oMap in your php code from this:


to this:


share|improve this answer
I finished fixing that error, I'm still getting a Warning: [MapServer Error]: error.Warning: [MapServer Error]: msLoadMap(): (/home/Oviedo12/public_html/final/subway crowding/maps/maps/dynamic.map) in /home/Oviedo12/public_html/final/subway crowding/mapscripts/dynamicwms.php on line 13 –  user13653 Dec 18 '12 at 21:28
Yeah, that's a bad link to your dynamic.map file, you've got one too many 'maps' in the path. –  Mintx Dec 18 '12 at 21:32
I saw that error a while ago, but to my knowledge I have no idea what it mean. I don't use any file of that name. I think it has something to so with twitter bootstrap, as that's what I'm using for my frontend. –  user13653 Dec 18 '12 at 21:33
See edit x2 in my answer above. –  Mintx Dec 18 '12 at 21:36
After the x2 edit I still get the same error: Warning: [MapServer Error]: msLoadMap(): (…) in /home/Oviedo12/public_html/final/subway crowding/mapscripts/dynamicwms.php on line 13................Also, if i change it back to ms_newMapobj("../maps/dynamic.map"); is "kinda works". –  user13653 Dec 18 '12 at 21:43
show 5 more comments

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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