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: http://134.74.146.40/~Oviedo12/final/subway%20crowding/view.html
.
OpenLayers 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",
"mapscripts/dynamicwms.php",
{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.zoomToExtent(map.maxExtent);
map.addControl(new OpenLayers.Control.MousePosition({position: new OpenLayers.Pixel(0,0)}));
}
Map file code:
MAP
IMAGETYPE PNG
STATUS ON
IMAGECOLOR 255 255 255
PROJECTION
"init=epsg:4326"
END
SYMBOL
NAME 'circle'
TYPE ELLIPSE
POINTS 1 1 END
FILLED TRUE
END
OUTPUTFORMAT
NAME png
DRIVER "GD/PNG"
MIMETYPE "image/png"
IMAGEMODE RGB
EXTENSION "png"
END
OUTPUTFORMAT
NAME jpeg
DRIVER "GD/JPEG"
MIMETYPE "image/jpeg"
IMAGEMODE RGB
EXTENSION "jpg"
FORMATOPTION QUALITY=80
END
END # All map files must come to an end just as all other things must come to...
PHP code for dynamic render:
<?php
if (!extension_loaded("MapScript")) dl("php_mapscript.so");
$request = ms_newowsrequestobj();
foreach ($_GET as $k=>$v) {
$request->setParameter($k, $v);
}
$request->setParameter("VeRsIoN","1.0.0");
ms_ioinstallstdouttobuffer();
$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_layer->set("name","L_line");
$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->setConnectionType(MS_POSTGIS);
$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) ;
$oMap->owsdispatch($request);
$contenttype = ms_iostripstdoutbuffercontenttype();
if ($contenttype == 'image/png')
{
header('Content-type: image/png');
ms_iogetStdoutBufferBytes();
}
else
{
$buffer = ms_iogetstdoutbufferstring();
echo $buffer;
}
ms_ioresethandlers();
?>