phpmapscript imagemap creation

Doug Williams williams at WEBSAWYER.COM
Fri Jul 6 11:12:48 PDT 2007


Huey,

I'll cc: this to the list for others...

On Fri, 06 Jul 2007 09:20:58 -0500, Huey Brantley wrote
> Hi Doug,
> 
> I'm experimenting with creating a imagemap can just can't seem to 
> get it to work. I've read your mail at http://www.mail-
> archive.com/mapserver-users at lists.umn.edu/msg12670.html.
> 
> I am doing something very similar as you except I use two map files 
> to generate the imagemap. Here's what I have done, if you don't mind 
> look over it and see if I'm doing something just blatently wrong.
> 
> Ok, I create my map objects.
> 
> $mapfile = "vanderbilt";
> 
> $map = ms_newMapObj($mappath.$mapfile.".map");
> $mapoverlay = ms_newMapObj($mappath.$mapfile."overlay.map")
>

You don't show your mappath here, but since you are getting coords later you 
must have have it declared in your script.  I'm guessing that your second 
mapfile is called "vanderbiltoverlay.map!  Correct?  That has the ouputformat 
driver = imagemap, I again guess.  Correct?

 
> $img = $map->draw();
> $map_url = $img->saveWebImage();
> 

This creates an image and returns the URL to it.  Are you displaying the 
image alright in your web page?

> $img2 = $mapoverlay->draw();
> 
> // here is where things get odd
> // gives me a url to map code....
> // <map name="FACILITY" width="800" height="800"></map>
> $imagemap_url = $img2->saveWebImage();
> 

This is not correct.  Don't use saveWebImage, that does what you describe, 
returns a URL to the image you create.  You don't show coords above so I 
suspect that saveWebImage does not really utilize the imagemap driver 
properly.  You are not trying to create a web image, just trying to use the 
imagemap driver to create the <map>w/ areas and coords</map> to enable the 
imagemap in the browser.  All the imagemap driver does is create the <map> 
information. [In truth, what I state is what I suspect, I am not a 
phpmapscript developer, and have no connection to mapserver (other than I 
think it is supercool and promote it wholeheartedly).  Assefa let me know 
that (if I remember right) mapfile.c is the only real source for indepth 
info.  (Thanks Assefa)  Look for that if you are able to read through c 
code.  I have not yet had time to dig into that, but will.

> I've tried this as well...
> 
> $imagemap_data= $img2->saveImage($map->web->imagepath."/test.html",
> $mapoverlay);
> 

This one should write the <map> info to the file test.html.  Look at that 
with an editor, or load it into your browser and view the source and you 
should see the same stuff you are seeing below.


> I get the same thing....
> 
> Now here's something interesting...This
> 
> $imagemap_data= $img2->saveImage("",$mapoverlay);
> 
> gives me the coords for my polys at the top of my page...stdout.
> 

Yes, this method, where you do not declare where the output should be written 
writes to stdout by default.  While I in my example write the file and 
then "require" it into my html returned to the server, it could have been 
achieved this way without saving the <map> info to a file, but just sending 
it straight into the html returned to server.  I have not tried this way.  It 
sounds like you are seeing the coords on your web page.  If that is true, 
then maybe this returns the coords without the prefixed <map> and postfixed 
</map>.  If that seems right, try writing <map>, then execute the command as 
above, then write </map>, and you should not see the coords on your web page, 
but they should be in the html if you look at the source.

I am out of town for a week or so and will have limited access to email.  
Hope this helps.  Let me know what you find. -Doug


> So, it seems I'm doing almost the same thing as you but just isn't
> working. What MapServer, Apache and PHP versions are you using?
> 
> Thanks,
> Huey Brantley
> Vanderbilt University



More information about the MapServer-users mailing list