phpmapscript imagemap attributes

Doug Williams williams at WEBSAWYER.COM
Wed Jul 4 10:31:51 EDT 2007


Assefa,

Again, no worries.  I'm serious that taking the time to try to explain to you what I was finding did 
help me to understand what was going on.  I do not understand how you were trying to reproduce 
what I was doing.  I did not know the map SIZE had three components.  I thought that the docs 
indicated that there was just a width and height to the size (in pixels).  Perhaps that is why you could 
not reproduce my results.

Best,


On Wed, 04 Jul 2007 09:03:45 -0400, Yewondwossen Assefa wrote
> Doug,
> 
>   Sorry for the late answer. I just tried your map file with your 
> data. Just using php mapscript :   $map_file="c:/msapps/tmp/bug_imagemap_doug/test.map";
> $gpoMap = ms_newMapObj("$map_file");
> $img = $gpoMap->draw();
> $url = $img->saveWebImage();
> 
> Doug Williams wrote:
> > I see now how the classitem is just cramed into the title for the 
> > imagemap areas.  With a little jiggling out the generated imagemap 
> > output I think I can create what I want.
> > 
> > And I suppose that the squishing of the shape file to fit the image size 
> > was the problem with the coords.  Agreed?
> >
> 
>   I could not reproduce this : I tried different map size (smallest 
> I tried is  SIZE 2 2 2). I get  coords that look like:  coords=" 1,
> 0" or coords=" 0,0" but never with empty values. Not sure if my 
> tests are significant.
> 
> > Thanks for responding to my plea for help.  Discussing it with you this 
> > way helped me to realize what was going on.
> >
> 
> The formatoptions docs available is the source code (mapimage.c). I 
> think that is all the docs that exists afaik. There is a desciption 
> of it at the begining but looking through the code, I see that some 
> format options are used but not described such as (SYMBOLHREF, 
> SCRIPT, DXF, SKIPENDTAG). It would be nice to update the 
> http://mapserver.gis.umn.edu/docs/howto/imagemaps at one point but I 
> am not familiar enough to do it.
> 
> Later,
> 
> > Cheers,
> > Doug
> > 
> > 
> > On Jun 29, 2007, at 6:17 AM, Yewondwossen Assefa wrote:
> > 
> >> Doug,
> >>
> >>  I am not very familiar with imagemap output but what I can certainly 
> >> do is test the output results and see why there is a problem with the 
> >> "coords" output, if you provide me a simple map and data. Note that I 
> >> will do the tests with Mapserver svn (to be 5.0 release).  Note that I 
> >> did a couple of tests with tests data that I have here and the 
> >> "cooords" result seem to be correct.
> >>
> >> Later,
> >>
> >> Doug Williams wrote:
> >>> Hi All, Jeff, Assefa, I have made a phpmapscript to generate an 
> >>> imagemap for my drawn map so when mousing over the map information 
> >>> about the shp below the mouse cursor is displayed beside the cursor.  
> >>> I like the way it works,
> >>>   http://www.wildweb.org/imagemap/
> >>> except for a couple of questions!  I am using version 4.8 on linux.
> >>> 1) Some of the polygon coords for the map areas begin with a comma, 
> >>> such as
> >>> <map name="map_test" width="600" height="300">
> >>> <area onMouseOver="handleClick(event,'boxinfo','show it',' NAME '); 
> >>> return false;" onMouseOut="handleClick(event,'boxinfo','hide it',''); 
> >>> return false;" title="" shape="poly" coords=" 96,70, 96,69, 95,68, 
> >>> 105,68, 105,73, 101,73, 101,74, 95,74, 95,73, 93,73, 94,72, 93,72, 
> >>> 93,70, 92,70, 92,69, 93,70, 95,70, 96,70, 96,71, 95,71, 95,72, 96,71, 
> >>> 96,70" />
> >>> <area onMouseOver="handleClick(event,'boxinfo','show it',' NAME '); 
> >>> return false;" onMouseOut="handleClick(event,'boxinfo','hide it',''); 
> >>> return false;" title="" shape="poly" coords=", 95,69" />
> >>> ......
> >>> </map>
> >>> Notice how the coords for the second area begin with a comma.  Does 
> >>> that mean I have a bad shape file?  Those commas seem problematic for 
> >>> some browsers when using the imagemap.  If I delete the commas by 
> >>> brute force and then display the edited html file, the imagemap works 
> >>> properly in all the browsers I have checked, although I guess that 
> >>> the areas with just two coords are not good...
> >>> 2) I cannot figure how to get the attribute data for the shape.  The 
> >>> cgi version of mapserver describes using a template, but where the 
> >>> cgi version describes the use of templates for other tasks, I have 
> >>> not found them useful for phpmapscript version, nor am I using, for 
> >>> this script, the header and footer templates as described in the cgi 
> >>> version imagemap creation tutorial, as setting the OUTPUTFORMAT 
> >>> driver to imagemap along with the correct FORMATOPTIONs generates 
> >>> everything as described in the cgi version tutorial, except I am not 
> >>> understanding how to get the attribute data other than the shp coords.
> >>> The cgi version says the the mode would need to be set to nquery.  I 
> >>> think this means that phpmapscript does a drawQuery().  Attempting 
> >>> this results in:
> >>> Warning: [MapServer Error]: msDrawQueryMap(): Unable to initialize 
> >>> image. in /.../index.php on line 184
> >>> Fatal error: Call to a member function on a non-object in 
> >>> /.../index.php on line 185
> >>> It does not seem necessary to use drawQuery().  draw() provides the 
> >>> coords as desired (w/ the question about the commas above).
> >>>  My belief is that I would grab the attribute data in the 
> >>> FORMATOPTION statement.  Am I on the right track?  Does this 
> >>> capability exist as part of the OUTPUTFORMAT imagemap driver in 
> >>> phpmapscript?
> >>> This is my OUTPUTFORMAT to create the imagemap:
> >>>  OUTPUTFORMAT
> >>>      NAME imagemap
> >>>      DRIVER imagemap
> >>>      FORMATOPTION "MAPNAME=map_test"
> >>>      FORMATOPTION "POLYHREF="
> >>>      FORMATOPTION "POLYMOUSEOUT=handleClick(event,'boxinfo','hide 
> >>> it',''); return false;"
> >>>      FORMATOPTION "POLYMOUSEOVER=handleClick(event,'boxinfo','show 
> >>> it','%NAME%'); return false;"
> >>>      FORMATOPTION "TITLE="
> >>>      MIMETYPE "text/html"
> >>>   END
> >>> The %NAME% was based on the sections discussing cookie variables and 
> >>> such, and NAME just ends up displayed without the % chars.  [NAME] as 
> >>> shown in the cgi version doc produces [NAME] as output.  I have tried 
> >>> escaping the ' char with \, but that results in an error.  Is there a 
> >>> code to put in the FORMATOPTION statement to obtain attribute data?
> >>> Does the layer definition matter?  Here is my layer definition:
> >>>     LAYER
> >>>       NAME "lakes"
> >>>       DATA esri/world/lakes
> >>>       STATUS on
> >>>       PROJECTION
> >>>           "proj=latlong"
> >>>       END #projection
> >>>       TYPE POLYGON
> >>>       METADATA
> >>>         "DESCRIPTION" "Lakes"
> >>>         "RESULT_FIELDS" "NAME SURF_ELEV DEPTH"
> >>>       END
> >>> #      HEADER "lakes_header.html"
> >>> #      FOOTER "lakes_footer.html"
> >>>       TEMPLATE ""
> >>>       CLASS
> >>>         NAME "States"
> >>>         OUTLINECOLOR 0 0 0
> >>>       END
> >>>     END
> >>> I have tried this with a couple of different layers and like the 
> >>> imagemap result (aside from not understanding why some area coords 
> >>> begin with a comma), but without the attribute data I am not sure 
> >>> what to do with it!
> >>> All ideas would be much appreciated,
> >>> Doug
> >>
> >>
> >> ------------------------------------------------------------------
> >> Assefa Yewondwossen
> >> Software Analyst
> >>
> >> Email: assefa at dmsolutions.ca
> >> http://www.dmsolutions.ca/
> >>
> >> Phone: (613) 565-5056 (ext 14)
> >> Fax:   (613) 565-0925
> >> ----------------------------------------------------------------
> > 
> >
> 
> -- 
> ----------------------------------------------------------------
> Assefa Yewondwossen
> Software Analyst
> 
> Email: assefa at dmsolutions.ca
> http://www.dmsolutions.ca/
> 
> Phone: (613) 565-5056 (ext 14)
> Fax:   (613) 565-0925
> ----------------------------------------------------------------



More information about the mapserver-users mailing list