/
Use HTML in Attributes

Use HTML in Attributes

Overview

In this example we create some HTML code, which will open a URL in a new window, as a Layer’s attribute value.

Normally we would select the Link field in Studio and check the checkbox to generate a hyperlink for the field. Studio currently doesn’t support the creation of a hyperlink for a new tab/window directly but it does provide an opportunity to see how html can be stored in a layer’s field.

The following steps presume that you're using a table in PostgreSQL but this can work for other sources such as a Shape file or MapInfo tab file.

  • Open PgAdmin, and use the SQL dialogue to create a column in your table.

  • Populate the column with some HTML that includes the link with the target parameter.

  • Alter the SQL in the MapServer .map file to include the myhtml column as myhtml_raw - this will ensure that the HTML is passed through without alteration.

LAYER   NAME "mylayer"   STATUS OFF   TYPE POINT   INCLUDE "datashare.inc"   DATA "wkb_geometry from (select *, myhtml as myhtml_raw from public.mytable) as foo using unique ogc_fid using srid=27700"   TOLERANCE PIXELS   CLASS     NAME ""     STYLE       SYMBOL "circle"       SIZE 14     END   END  END
  • In Studio include myhtml_raw to in the list of columns displayed. 

Make sure you include the http:// in the myhtml column - failing to so will result in the browser attempting to load the page as a local resource.

 

Related content

Link to a File from iShare GIS Information Browser
Link to a File from iShare GIS Information Browser
More like this
Add a simple URL
Add a simple URL
More like this
Allow links on my MyHouse or MyNearest pages to open in new browser tab
Allow links on my MyHouse or MyNearest pages to open in new browser tab
More like this
MapServer LAYER>CLASS>STYLE Object
MapServer LAYER>CLASS>STYLE Object
More like this
Enable iShare Maps Permalink Plugin
Enable iShare Maps Permalink Plugin
More like this
Create a Google StreetView layer
Create a Google StreetView layer
More like this