Opened 19 years ago

Last modified 19 years ago

#1370 new defect

HTML legend broken with 4.6b2/b3

Reported by: dmorissette Owned by: dmorissette
Priority: high Milestone:
Component: MapServer C Library Version: 4.8
Severity: normal Keywords:
Cc: kenlord@…

Description

This was initially posted in bug 1363, but should deserve its own bug:
---

Hello debuggers,

MapServer 4.6 broke my dynamic HTML legend template. The legend is not 
inserted into the webpage.

I noticed this bug report, and have tried 4.6b3, but it is still broken.

My template uses some javascript to format the appearance of groups of layers 
and to add a control that turns all layers of a group on/off at once.  The 
template has worked fine with versions 3.6 to 4.4.2, windows CGI.

Below is the contents of my legend template.

Thanks,
Ken Lord
Vancouver BC

[leg_group_html]
<tr>
<script type="text/javascript">
<!--
var theGroupColor; var theLayerColor;

function GROUPCOLOR(groupname){
  //-- Color the Group and Layer headings according to the group name --//
  switch(groupname){
    case "Hazard Prediction Values":
      theGroupColor="#DC143C";
      theLayerColor="#FFAAAA";
      break;
    case "Features":
      theGroupColor="#009966";
      theLayerColor="#66DD99";
      break;
    case "Province":
      theGroupColor="#3366CC";
      theLayerColor="#66CCFF";
      break;
    case "Rasters":
      theGroupColor="#CC6633";
      theLayerColor="#FFAA77";
      break;
    default:
      theGroupColor="#A9A9A9";
      theLayerColor="#DDDDDD";
      break;
  }
  return theGroupColor;
}

function MapSubmit(){
  //mapForm.INPUT_COORD.value="";
  mapForm.zoomdir.value="0";
  mapForm.mode.value="browse";
  mapForm.target="_self";
  mapForm.submit();
}

//== Parse together a URL to follow that controls if a legend group is ON or 
OFF ==//

function checkURLon(group){
  var theURL;  var check; var theOldURL=document.URL;
  var beginning="HREF='";
  var ending="'><IMG src='../Mining/MapServer/mapserver/images/sun.gif' 
height='15' width='15' border='0' valign='bottom' alt='Turn All Layers within 
this Group ON'"

  theURL=beginning + "../Mining/MapServer/TurnLayers_HBFlinFlon.asp?group=" + 
group + "&switch=ON&address=" + theOldURL.replace(/&/g,"^") + ending;

  check=theOldURL.indexOf('?');
  if(check==-1){
    theURL="><IMG src='../Mining/MapServer/mapserver/images/sunred.gif' 
height='15' width='15' border='0' valign='bottom' alt='Tool not Available'";
  }
//  if(group=="Rasters"){
//    theURL="";
//  }
  return theURL;
}

function checkURLoff(group){
  var theURL;  var check; var theOldURL=document.URL;
  var beginning="HREF='";
  var ending="'><IMG src='../Mining/MapServer/mapserver/images/sunOFF.gif' 
height='15' width='15' border='0' valign='bottom' alt='Turn All Layers within 
this Group OFF'"

  theURL=beginning + "../Mining/MapServer/TurnLayers_HBFlinFlon.asp?group=" + 
group + "&switch=OFF&address=" + theOldURL.replace(/&/g,"^") + ending;

  check=theOldURL.indexOf('?');
  if(check==-1){
    theURL="><IMG src='../Mining/MapServer/mapserver/images/sunOFFred.gif' 
height='15' width='15' border='0' valign='bottom' alt='Tool not Available'";
  }
//  if(group=="Rasters"){
//    theURL="";
//  }
  return theURL;
}


function counter(){
 switch("[leg_group_name]"){
     case "Hazard Prediction Values":
       count="1";
       break;
     case "Features":
       count="2";
       break;
     case "Surfaces":
       count="3";
       break;
     case "Rasters":
       count="4";
       break;
     default:
       count="0";
       break;
   }
  return count;
}
//-->
document.write("<td height='26' bgcolor=" + GROUPCOLOR('[leg_group_name]') + " 
colspan=2>");
document.write("<font face='Verdana, Arial, Helvetica, sans-serif' 
color='#FFFFFF' size='1'><b>");
document.write("<a href='#' target='_self' onclick=javascript:OpenHelp
('../Mining/MapServer/help_Layers.htm') onMouseOver=javascript:imgON('help" + 
counter() + "') onMouseOut=javascript:imgOFF('help" + counter() + "')><img 
name='help" + counter() + "' border='0' 
src='../Mining/MapServer/mapserver/images/help_off.gif' alt='Help: Layer 
Controls'></a>");
document.write("  <a " + checkURLon('[leg_group_name]') + "></a><a " + 
checkURLoff('[leg_group_name]') + "></a>");
</script>

 [leg_group_name]</b></font>


    </td>
</tr>
[/leg_group_html]

[leg_layer_html order_metadata=WMS_ORDER visibility_flag=15 opt_flag=7]
<tr>

<script>
document.write("<td colspan='2' height='26' bgcolor=" + theLayerColor + ">");
</script>
	   [if name=layer_status oper=neq value=2]
	     <input type=checkbox name="layer" value="[leg_layer_name]" 
onClick="MapSubmit()" [[leg_layer_name]_check]>
	   [/if]
	   <font face="Verdana, Arial, Helvetica, sans-serif" color="#666666" 
size="1"><b>[metadata name=WMS_TITLE]</b></font><br>
	</td>
</tr>
[/leg_layer_html]
[leg_class_html visibility_flag=15]
<tr>
	<td colspan="2" bgcolor="#FFFFFF"><font face="Verdana, Arial, 
Helvetica, sans-serif" color="#666666" size="1"><img src=[leg_icon] 
alt="[metadata name=WMS_ABSTRACT]"> [leg_class_name]</font><br> </td>
</tr>
[/leg_class_html]

Change History (3)

comment:1 by dmorissette, 19 years ago

Cc: kenlord@… added
Owner: changed from sdlime to dmorissette@…
Is the legend really not output by MapServer at all, is it a JavaScript error
that prevents it from being displayed? Please quote the exact output (HTML
view-source) and the error message from the JavaScript log window is there is one.

We may be able to find the source of the problem with the above, if not then
we'd need a full testcase to reproduce, including mapfile, full templates, etc.

comment:2 by kenlord@…, 19 years ago

op_sys: LinuxWindows XP
Version: 4.54.6
Hi Daniel, thanks for your response,

No error is produced either for javascript, or in the MapServer logs. The 
website otherwise loads properly without error and the legend template 
continues to work properly with MapServer 4.4.2 on our new server.

My HTML template for the website uses a [legend] CGI parameter where the 
legend is to appear on the page.  MapServer 4.6 takes out the "[legend]" but 
instead of parsing in the dynamic legend in its place, it leaves a blank line 
in the HTML template.

We're going through a server upgrade here, I can give you a link to the 
working older version (below), to show you what it should look like, but the 
new version is only accessible on our intranet at the moment.

http://www.groundcontrol.info/demos/mining/index.htm

Within the HTML code, the dynamic legend starts at the green coloured block on 
the website.

Thanks,
Ken

comment:3 by kenlord@…, 19 years ago

Version: 4.64.8
A long awaited update to this problem ...

The problem affects 4.8 beta as well as the older 4.6 series and has been 
described by 2 or 3 people on the email list.

The html legend crashes consistantly when you try to display a polygon layer 
where their is a style filling the polygon and a second style drawing the 
polygon outline using a cartoline type symbol for the line with antialias set 
to true within the style.

Here's an example layer, adding the antialias parameter where it is seen 
remmed out below triggers the problem.


LAYER
  NAME "Test_Pits"
  TYPE POLYGON
  STATUS ON
  CONNECTIONTYPE postgis
  CONNECTION "user=xxx password=xxx dbname=xxx host=192.168.xxx.xxx"
  DATA "wkb_geometry from bgc_test_pits"  
  PROJECTION
      "init=EPSG:26910"
  END
  LABELITEM "Text"
  LABELMAXSCALE 500  
  HEADER "results/Test_Pits_header.html"
  TEMPLATE "results/Test_Pits_results.html"
  TOLERANCE 1
  TOLERANCEUNITS pixels
  CLASS
      NAME "BGC Test Pits"
      STYLE
    	COLOR 200 215 140
      END
      STYLE
  	SYMBOL "cartoline"
  	#ANTIALIAS TRUE        
    	OUTLINECOLOR 130 160 80
      END
      LABEL
	ANGLE AUTO
	POSITION AUTO
	ANTIALIAS TRUE
	OUTLINECOLOR 255 255 255
	FONT "arial"
	COLOR 0 0 0
	TYPE truetype
	SIZE 7
	MINSIZE 6
	MAXSIZE 8
	FORCE FALSE
	PARTIALS TRUE
      END           
  END
END

My cartoline symbol is defined by:

SYMBOL   
  NAME "cartoline"
  TYPE cartoline
  LINECAP BUTT
  LINEJOIN round
  LINEJOINMAXSIZE 3 
END

Cheers,
Ken Lord
Vancouver BC
Note: See TracTickets for help on using tickets.