[mapserver-users] returning mouse click coordinates to PHP

Scott D Cogan cogansco at msu.edu
Wed Mar 27 10:03:54 PST 2002


antti-
thanks so much for your help!  i think you are right.  mapscript and PHP is
the way to go.  i loaded the dll files, and i believe they loaded
successfully, however, i got an error when i used the following code:

<?
$map = ms_newMapObj("C:\\Program Files\\Apache\\htdocs\\mich\\demo.map");
$img = $map->prepareImage();
$img = $map->draw();
$url = $img->saveWebImage(MS_GIF, 0, 0, 0);
printf("<INPUT type=image name=click SRC=%s>", $url);
?>

the errors:

Warning: MapServer Error in loadSymbol(): (TRUE):(84) in c:\program
files\apache\htdocs\testing.php on line 2

Fatal error: Failed to open map file C:\Program
Files\Apache\htdocs\mich\demo.map in c:\program
files\apache\htdocs\testing.php on line 2

the file exists and works fine with the CGI version.  i know the address is
correct because if i change it to something invalid, i get a different
error:

Warning: MapServer Error in msLoadMap(): (C:\Program
vbnFiles\Apache\htdocs\mich\demo.map) in c:\program
files\apache\htdocs\testing.php on line 2

  any ideas?
-scott



----- Original Message -----
From: <Antti.Roppola at brs.gov.au>
To: <cogansco at pilot.msu.edu>
Sent: Monday, March 25, 2002 9:55 PM
Subject: RE: [mapserver-users] returning mouse click coordinates to PHP


> Bingo. Mapserver.exe is the CGI program
> and *not* the PHP extension.
>
> Compile (or download) PHP/Mapscript which is
> an extension for PHP, viz it gives a pile of new
> PHP functions like "ms_newMapObject()". It is run
> as a CGI, but (I think) called by PHP/IIS/Apache
> and not by your page.
>
> You *could* get PHP to drive Mapserver.exe and
> load the results into PHP yourself, but Mapscript
> will implement all the Mapserver.exe functionality
> inside PHP for you, making it faster and avoiding
> the need to address the problem you outline below.
>
> Adding something like this to a PHP page:
>
> $map = ms_newMapObject("some_map.map");
> $img = $map->prepareImage();
> $img = $map->draw();
> $url = $img->saveWebImage(MS_PNG, 0, 0, 0);
> printf("<INPUT type=image name=click SRC=%s>", $url);
>
> Should display the loaded map in its default state.
>
> If you do not have PHP/Mapscript, it will error and complain
> it dosn't know how to do ms_newMapObject().
>
> Cheers,
>
> Antti
>
>
> -----Original Message-----
> From: Scott Cogan [mailto:cogansco at pilot.msu.edu]
> Sent: Tuesday, 26 March 2002 1:06 PM
> To: Antti.Roppola at brs.gov.au
> Subject: RE: [mapserver-users] returning mouse click coordinates to PHP
>
>
> thanks for your help...
> i have tried renaming the file to .php, and i have confirmed that php
> files work.  i installed PHP long before mapserver.  what is this
> mapscript thing, though?  i use mapserver.exe.  thats the problem.  i
> run the demo_init.html and then after that my URL is actually
> ...cgi-bin/mapserver.exe?xxxx=xxxx&yyy=yyy... etc.  see what my
> problem is?
> -scott
>
>
>
> >Try renaming it .php or creating a PHP "Hello Word"
> >program to make sure your web server is recognising
> >PHP files correctly before trying to get PHP/Mapscript
> >to work:
> >
> > <HTML>
> > <BODY>
> > <?php echo("Hello World!"); ?>
> > </BODY>
> > </HTML>
> >
> >
> >There's a good set of instructions for configuring
> >Win32 PHP with both Apache and IIS on the PHP website:
> >http://cvs.php.net/co.php/php4/win32/install.txt
> >
> >I have the core bits listed below, but read the whole
> >document as there are potentially nasty pitfalls you should
> >be aware of before starting.
> >
> >For Apache (httpd.conf):
> > ScriptAlias /php/ "c:/php/"
> > AddType application/x-httpd-php .php
> > Action application/x-httpd-php "/php/php-cgi.exe"
> >For IIS:
> > Run Regedit.
> > Navigate to:
> >
> >
HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/W3Svc/Parameters/Script
Map
> > On the edit menu select: New->String Value.
> > Type in the extension you wish to use for your php scripts. ex: .php
> > Double click on the new string value and enter the path to
> > php-cgi.exe in the value data field.
> > ex: c:\php\php-cgi.exe
> > Repeat these steps for each extension you wish to associate
> > with PHP scripts.
> >
> >Cheers,
> >
> >Antti
> >
> >
> >-----Original Message-----
> >From: Scott Cogan [mailto:cogansco at pilot.msu.edu]
> >Sent: Tuesday, 26 March 2002 11:06 AM
> >To: Antti.Roppola at brs.gov.au
> >Subject: RE: [mapserver-users] returning mouse click coordinates to PHP
> >
> >
> >i tried this, but i am editing the demo.html file that came with the
> >"itasca" demo and i dont believe that PHP is processing anything.  i
> >am using the cgi-executable version for windows.  is there any way to
> >use a PHP script instead of using the executable program directly as
> >a cgi-bin program?
> >-scott
> >
> >
> >
> >>Display your map as a input type image:
> >>
> >><INPUT TYPE=IMAGE NAME=click BORDER=0
> >>SRC=/mapserv/tmp/1017094226964495.png WIDTH=600 HEIGHT=600>
> >>
> >>This example will generate $click_x and $click_y as PHP
> >>variables in whatever form it submits to. Then write a
> >>little function to translate these image coordinates to
> >>map coordinates.
> >>
> >>The GMap demo has such a function, but because it does drag boxes
> >>and stuff, it's a bit more complicated to read. I am currently
> >>using GMap's query function though (as it worked "out of the box").
> >>
> >>There are functions in Mapserver that let you set a tolerance
> >>for point identifys, "click selects any points within XX pixels"
> >>
> >>
> >>Cheers,
> >>
> >>Antti
> >>
> >>-----Original Message-----
> >>From: Scott D Cogan [mailto:cogansco at msu.edu]
> >>Sent: Tuesday, 26 March 2002 8:58 AM
> >>To: mapserver-users at lists.gis.umn.edu
> >>Subject: [mapserver-users] returning mouse click coordinates to PHP
> >>
> >>
> >>i have a map up with certain sites mapped as a layer of type POINT.
these
> >>sites are displayed on the map just fine, but i would like to be able to
> >>have users click on the actual map and somehow determine, maybe with
PHP??
> >>what coordinates (lat and long) were clicked so that i could bring up
> >>site-specific info on the site that they click near.  any ideas?  thanks
> >>-scott
>
>




More information about the MapServer-users mailing list