[OpenLayers-Users] How to use WMS, PHP MAPScript and Openlayers (all together :-) )

"tschobber tschöbbi" tschobber at gmx.at
Thu Apr 2 06:40:18 EDT 2009


Hi,

thanks for the answer! Ok that's working with a single php file with JUST the following code:

index.php:

---------------------------------------------------
<?php


dl ("php_mapscript.so");

$request = ms_newowsrequestobj();

$request->loadparams();

ms_ioinstallstdouttobuffer();



 $map_path="/srv/www/myParams/";
 $map = ms_newMapObj ($map_path."myMap.map");
 $layer = $map -> getLayerByName("raster");
//$status = $layer->open();
 $layer->set('data', "map_t20000301.png");



$map->owsdispatch($request);

$contenttype = ms_iostripstdoutbuffercontenttype();

if ($contenttype == 'image/png')
      header('Content-type: image/png');

 if ($contenttype == 'EPSG:31297')
       header('Content-type: EPSG:31297');


ms_iogetStdoutBufferBytes();

ms_ioresethandlers();

?>
--------------------------------------------
When I put some html code into index.php my picture is shown in special characters and I get a header warning (see below). Why is this? (if you could have a look at this file I would be very glad --> attached as index.php)

Headerwarning:
---------------------------------------------------
Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/test.php:7) in /srv/www/htdocs/index.php on line 50
---------------------------------------------------


Secondly how can I create a Layer in Openlayers that calls this index.php file... by just adding a layer like this?: 

var indexlayer = new OpenLayers.Layer.WMS("test","http://localhost/klima/index.php?",{format:'image/png'});

I've tried that, but Openlayers shows me nothing.


thanks for answers!



-------- Original-Nachricht --------
> Datum: Wed, 1 Apr 2009 17:01:52 +0300
> Von: Pavel Iacovlev <iacovlev.pavel at gmail.com>
> An: "tschobber tschöbbi" <tschobber at gmx.at>
> Betreff: Re: [OpenLayers-Users] How to use WMS, PHP MAPScript and Openlayers 	(all together :-) )

> How to change data parameter
> 
> $map = ms_newMapObj($mapFile);
> $layerobj = $map->getLayerByName('layerName');
> $layerobj->set('data', "the_geom from ($select) as tmp using SRID=$srid
> using unique $unique");
> 
> WMS spits out text and images, that code just checks what WMS wants to do
> right now and sets the correct headers.
> 
> 2009/4/1 "tschobber tschöbbi" <tschobber at gmx.at>
> 
> > Hi,
> >
> > I have the following problems:
> >
> > I've seen the following example how to use PHP Mapscript with WMS -
> here's
> > the link to the example:
> >
> > http://mapserver.org/ogc/mapscript.html#php-example
> >
> > I have a index.php file - in this file I load an OpenLayers (.htm) file
> > that shows a map. My intention is to modify/switch a single parameter
> (in my
> > case the "DATA" attribute) in the .map file dynamically with PHP
> Mapscript
> > (PHP function in index.php) and Openlayers (WMS) should show me the new
> map
> > affected by the changed parameter but using the same shapefile.
> >
> > I.e if this is a layer of my mapfile - I want to dynamically switch
> > "DATA "testA.png" to "DATA "testB.png" over WMS/Openlayers"
> >
> > in the index.php :
> >
> > LAYER
> > NAME "test"
> > DATA "testA.png"
> > TYPE RASTER
> > STATUS ON
> > UNITS METERS
> > PROJECTION
> > "init=epsg:31297"
> > END
> >                METADATA
> >  "wms_name" "blayer"
> >  "wms_title" "blayer"
> >  "wms_srs" "EPSG:31297"
> > END
> > END
> >
> > Concerning the code of the tutorial:
> >
> > How am I able to change this "DATA" object in the above layer with php
> > mapscript? The following code looks very suspicious to me - is this code
> > changing the Format type? If yes I want to do the same with the DATA
> object
> > - but how?
> >
> > $contenttype = ms_iostripstdoutbuffercontenttype();
> >
> > if ($contenttype == 'image/png')
> >   header('Content-type: image/png');
> >
> > Would be very cool if someone could help me.
> >
> > best regards + thanks!
> >
> >
> >
> >
> >
> >
> > --
> > Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate +
> > Telefonanschluss für nur 17,95 Euro/mtl.!*
> > http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
> 
> 
> 
> -- 
> http://iap.md, The future is open

-- 
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
-------------- next part --------------
A non-text attachment was scrubbed...
Name: index.php
Type: application/x-php
Size: 1691 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090402/09f18813/index.bin


More information about the Users mailing list