![]() |
Template RequirementsIt is important to understand the following terminology and concepts:
Widget BasicsWidgets are represented in an HTML template using familiar HTML-like notation. (Actually, the tags conform to XML specifications, which are a super-set of HTML, but that isn't important here.) As such, tags are written using the standard HTML opening and closing brackets with the additional requirement that the tags be complete. This means that every tag must have a closing element. There are two valid ways of closing a tag. The first is to include a "/" before the closing bracket of the first tag. The second is to include a second tag that uses the same name as the opening tag but starts with a "/". CWC TagHere are examples of minimal valid Chameleon CWC2 tags:
<CWC2/>
and
<CWC2></CWC2>
These simple tags above don't actually represent any functionality and would be ignored by the Chameleon HTML parser. "CWC2" is the marker used so that other HTML tags (for styling, tables, etc.) can be distinguished from Chameleon tags. Defining A WidgetIn order to create a tag that represents an actual Chameleon widget, you need to add a TYPE attribute to the tag:
<CWC2 TYPE="WidgetName"/>
This CWC2 tag represents a widget called "WidgetName". Since there isn't a widget available by that name, the Chameleon HTML parser would generate an error if this tag was defined in an HTML template. The list of available widgets is documented in the Chameleon Widget Documentation. Your CWC2 Service Instance administrator may also have created additional widgets for you to use. Widget Configuration and FlexibilityMost widgets also require additional configuration attributes to be defined. These values are normally specified in one of two ways. The first, and most common, way is to specify other values in the CWC2 tag in the same way the TYPE attribute is specified. For example:
<CWC2 TYPE="WidgetName" TEST="false"/>
This creates a widget of TYPE "WidgetName" with a TEST attribute that is set to "false". Nested SubtagsSome widgets require (or allow) attributes to be passed as nested tags inside a CWC2 tag. This is often caused by the widget requiring a list of a common attributes or groups of dependent attributes. For example:
<CWC2 TYPE="WidgetName">
<TEST value="1"/>
<TEST value="2"/>
</CWC2>
This allows for multiple copies of nested tags and attributes. Nested tags have the same formatting restrictions as CWC2 tags in that they must be closed properly. Widgets that require nested tags will specify the necessary format in their documentation. Often Shared Resources widgets are structured in this manner. Widget Attributes that Point To FilesEven though this topic is related to individual attributes it is important enough to be included in widget basics. In some cases, widget attributes hold a string value that defines a path to a file to be used. The file could be used for anything that the widget may need, including an image for a button, a map file to display a map, XML code, or even another HTML template. Defining these paths properly so that they can be understood by Chameleon can be confusing. Chameleon tries to locate these files in any possible location that it could be found, based on the configuration for each widget attribute path. These paths can be defined as:
Building a TemplateThis section of the guide discusses the following details:
First Step - The GoMMaP Sample HTML TemplateYou will typically create a new Chameleon application by copying an existing template and making changes to it specific to what you need. To help you, the Gulf of Maine Data Framework has provided a sample template for downloading. All GoMOOS organizations that wish to develop their own Web mapping application(s) can start with this basic sample template. Of course, depending on your confidence with the Chameleon technology and HTML in general, you can also create an application template from scratch. However, it is much simpler to modify a more complete file. Where can I Download this GoMMaP Sample HTML Template?You can get this template here. Second Step - Understanding Your TemplateWhether you are using the GoMMaP Sample HTML Template, your own template, or starting from scratch, it is important to understand the basic requirements for a Chameleon HTML Template. The discussion below assumes that you are starting with no template. This does not mean that people with an existing Chameleon HTML template cannot follow along and find these features within their templates. If you wish, you can follow section this like a tutorial and build your own simple template. What are the Basic Requirements?The basic requirements for Chameleon to read and parse your HTML web mapping application template are that all the following features are in your template:
What does the Basic HTML Template Look Like?Below is a sample of a minimal HTML template that is correctly configured for the Chameleon parser. Can you see all the required elements listed above?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Widgets</title>
<link href="cwc2.css" rel="stylesheet" type="text/css">
</head>
<!-- All Shared Resources can be placed at the top of Template. -->
<body onload="CWC2OnLoadFunction()">
<!-- All other Chameleon Widgets live between the form elements. -->
<form>
</form>
</body>
</html>
Third Step - Adding a Map WidgetNow that you have a valid Chameleon HTML template, you can define further mapping elements for your application. The Chameleon mapping application elements are defined as "widgets" in the HTML template. The most basic mapping element of any application is a map itself. The widget type to be added to the template is called "MapDHTMLWidget". How is the Map Widget Defined?This Map widget requires the following widget attributes:
Additional optional attributes are as follows. Many of the following attributes have default values which are used most of the time.
NOTE: Detailed information for this widget and all attribute descriptions can be found in the Chameleon Widget Reference Document. Here is what the tag looks like as implemented in this ongoing example:
<CWC2 TYPE="MapDHTMLImage"
VISIBLE="true"
WIDTH="400"
HEIGHT="300"
ALLOWRESIZE="true"
MARQUEECOLOR="#FF3333"
MARQUEEWIDTH="2"
MINSCALE="1"/>
How do I Place the Map Widget in my Chameleon HTML Template?All widgets must be added inside the <form></form> tags on the page, but they can be inline with any other HTML formatting tags, such as those for tables. Here is an example of how the map image widget might be included in the default template from before:
<html>
<head>
<title>Widgets</title>
<link href="cwc2.css" rel="stylesheet" type="text/css">
</head>
<!-- All Shared Resources can be placed at the top of Template. -->
<body onload="CWC2OnLoadFunction()">
<!-- All other Chameleon Widgets live between the form elements. -->
<form>
<table border="0" cellspacing="2" cellpadding="0">
<tr>
<td colspan="3" align="center">
<!-- Display Map Here. -->
<CWC2 TYPE="MapDHTMLWidget"
VISIBLE="true"
WIDTH="400"
HEIGHT="300"
ALLOWRESIZE="true"
MARQUEECOLOR="#FF3333"
MARQUEEWIDTH="2"
MINSCALE="1"/>
</td>
</tr>
</table>
</form>
</body>
</html>
Fourth Step - Adding a Widget Shared ResourceDepending on which widgets are on your template and their dependencies, this step of Chameleon application development may be optional. As a Chameleon application developer it is hoped you will continue to expand the design complexity of your mapping interfaces - using Shared Resource is one way to help manage increasingly complex application interfaces. How is a Widget Shared Resource Defined?A Shared Resource is a widget that requires the following widget attributes:
These two required Shared Resource attributes help define what this widget represents. All the other widgets that use a Shared Resource help determine how that specific Shared Resource is defined. In other words, since a Shared Resource is a place holder for certain attributes of other widgets, it can take on many, many different forms. What Shared Resource Can I Use for this Template?The basic template defined above contains a widget called "MapDHTMLWidget". This widget can use the Shared Resource named "WaitImage". The WaitImage Shared Resource holds a language-specific, moving GIF image that is displayed if there is a prolonged waiting period during a user request. In this case, the "MapDHTMLWidget" widget use the wait image when the client is waiting for a new map image to load from the server. The "WaitImage" Shared Resource looks like the following:
<!-- WaitImage Shared Resource -->
<cwc2 type="SharedResource" name="WaitImage">
<waitimage language="en-CA"
waitimage="images/spinner.gif"
waitimagewidth="216"
waitimageheight="50"/>
<waitimage language="fr-CA"
waitimage="images/spinner_f.gif"
waitimagewidth="216"
waitimageheight="50"/>
</cwc2>
You will notice in the <waitimage.../> subtag that there are four attributes. The "language" attribute is actually correlated with the "Language" widget, where the language used in the template is defined. The other three attributes - "waitimage", "waitimagewidth", and "waitimageheight" - are actually valid attributed within the "MapDHTMLWidget" widget. (See above.) Instead of defining the three "waitimage"-based attributes within the map widget, use the "WaitImage" Shared Resource. How do I Place the WaitImage Shared Resource in My Chameleon HTML Template?In a previous step it was stated that "All widgets must be added inside the <form></form> tags...". Well, Shared Resource widgets are the exception. Shared Resources are not restricted to between <form> and </form> but, for general formatting and readability purposes, they should be placed above the <body> tag. In many complex Chameleon HTML templates, you will find more than one Shared Resource listed at this location.
<html>
<head>
<title>Widgets</title>
<link href="cwc2.css" rel="stylesheet" type="text/css">
</head>
<!-- All Shared Resources can be placed at the top of Template. -->
<!-- WaitImage Shared Resource -->
<cwc2 type="SharedResource" name="WaitImage">
<waitimage language="en-CA"
waitimage="images/spinner.gif"
waitimagewidth="216"
waitimageheight="50"/>
<waitimage language="fr-CA"
waitimage="images/spinner_f.gif"
waitimagewidth="216"
waitimageheight="50"/>
</cwc2>
<body onload="CWC2OnLoadFunction()">
<!-- All other Chameleon Widgets live between the form elements. -->
<form>
<table border="0" cellspacing="2" cellpadding="0">
<tr>
<td colspan="3" align="center">
<!-- Display Map Here. -->
<CWC2 TYPE="MapDHTMLWidget"
VISIBLE="true"
WIDTH="400"
HEIGHT="300"
ALLOWRESIZE="true"
MARQUEECOLOR="#FF3333"
MARQUEEWIDTH="2"
MINSCALE="1"/>
</td>
</tr>
</table>
</form>
</body>
</html>
Fifth Step - View the Chameleon ApplicationYour simplest of Chameleon HTML templates is now functional and ready to be used. You can now try to get Chameleon to parse this template in your browser using a Chameleon Service Instance and a map file. Please refer to the other associated documents for information on how to make this happen. Once you call the proper URL, the following things should happen:
Making is a "Real" ApplicationWhile the above sample application does not seem like much, creating it is a very important step in understanding how to build a more realistic Chameleon HTML template. Now that you have a working mapping application the world is your oyster. You can begin to add more widgets that interact with your map, like the "ZoomIn" and "ZoomOut" widgets:
<!-- ZOOM IN -->
<cwc2 type="ZoomIn" visible="true" imagetip="Zoom In" toolset="Navigation"
imagewidth="24" imageheight="24">
<image state="normal" image="buttons/button_zoomin_1.png"/>
<image state="hover" image="buttons/button_zoomin_2.png"/>
<image state="selected" image="buttons/button_zoomin_3.png"/>
</cwc2>
<!-- ZOOM OUT -->
<cwc2 type="ZoomOut" visible="true" imagetip="Zoom Out" toolset="Navigation"
imagewidth="24" imageheight="24">
<image state="normal" image="buttons/button_zoomout_1.png"/>
<image state="hover" image="buttons/button_zoomout_2.png"/>
<image state="selected" image="buttons/button_zoomout_3.png"/>
</cwc2>
If everything works, you should now have a navigable mapping application! GoMMaP Sample HTML TemplateFor details on the widgets discussed so far, as well as the other widgets found in the GoMMaP sample template, please go to the "GoMMaP - Chameleon Widget Reference" document. If you have not already done so, take a minute or two and review the information on all the widgets found in the GoMMaP Sample HTML Template. This Widget Reference can give you the information and confidence to enhance the GoMMaP Sample template and make it your own. Where to from Here?At this point, as a Chameleon application developer, you have the following options:
|