# Mouseover

This section allows you to define mouseover settings for the layer, such as the contents to be displayed, the color of the mouseover bubble, etc.

The mouseover configuration interface is as follows:

<figure><img src="https://content.gitbook.com/content/DUF1p2rT0hfE3QBlbbvE/blobs/3TS9vw3jyrNNCPyWKntG/infobulles-v5.png" alt=""><figcaption></figcaption></figure>

<table data-header-hidden><thead><tr><th width="76"></th><th></th></tr></thead><tbody><tr><td><strong>1</strong></td><td>The <strong>Attributes</strong> list allows you to select attributes and add them to the mouseover bubble's contents by pressing the button with the downward arrow.</td></tr><tr><td><strong>2</strong></td><td>The <strong>Functions</strong> list allows you to select content formatting functions (bold, italic, etc.) and to add these to the mouseover bubble's contents by pressing the button with the downward arrow.</td></tr><tr><td><strong>3</strong></td><td>Enter the mouseover bubble's contents. <br>This can include static text, as well as functions displaying attribute values, images, etc. <br>Mouseover bubbles also support javascript programming to perform mathematic operations as well as operations on character strings using attribute values.<br>For more information on defining the content of mouseover bubbles, refer to <a href="#creating-mouseover-content">Creating Mouseover Content</a>.</td></tr><tr><td><strong>4</strong></td><td>Select the mouseover bubble's background color for this layer.</td></tr><tr><td><strong>5</strong></td><td>The following options modify mouseover behavior. <br><strong>Mouse over visible</strong>: Enable or disable mouseover for the current layer. <br><strong>Prevent text duplication</strong>: Avoid having content repeat itself within a bubble.</td></tr><tr><td><strong>6</strong></td><td>Visibility thresholds define the scale range within which mouseover bubbles are displayed on the map. <br>If you do not select this option, the mouseover bubble will be displayed at all scales.</td></tr></tbody></table>

## Creating Mouseover Content

You must provide the text that will be used as mouseover content. This text can include static parts (displayed as is), variable parts (functions replaced by other values when the map is displayed), simple javascript programs as well as HTML tags. For example, the `element value(city)` function, or `ev(city)` in its abbreviated form, will be replaced by the value of the city attribute of the pointed element, when displayed.

The mouseover text can span multiple lines. Simply write the text over more than one line and the mouseover bubble will use the same formatting.

### **Mouseover syntax**

The mouseover syntax is comprised of various functions that will determine the content of the bubbles. Functions and their parameters are generally not case sensitive. For instance, `ev(city)` is equal to `Ev(CITY)`.

The following table explains the various available functions:

<table data-header-hidden><thead><tr><th width="232"></th><th></th></tr></thead><tbody><tr><td><strong>elementValue</strong>(<em>attrib</em>) or <strong>ev</strong>(<em>attrib</em>) <br><em>attrib</em>: the name of an attribute</td><td>Replaced by the value of the bound attribute whose name is passed as a parameter for the pointed element. <br>For example, <code>ev(id)</code> will be replaced by the value of the <em>id</em> attribute for this element.</td></tr><tr><td><strong>elementId</strong>()</td><td>Replaced by the element identifier.</td></tr><tr><td><strong>polygonArea</strong>()</td><td>Replaced by the area of a pointed polygon type element.</td></tr><tr><td><strong>lineLength</strong>()</td><td>Replaced by the length of a pointed line type element.</td></tr><tr><td><strong>centroid</strong>()</td><td>Replaced by the coordinates of the geometric centroid of the element's geometry.</td></tr><tr><td><strong>format</strong>(<em>attrib</em>, <em>format</em>)<br><em>attrib</em>: the name of a date or numerical attribute <br><em>format</em>: the desired date format</td><td>Replaced by a number or date that was formatted according to a specific format. <br><strong>Example</strong><br><code>format(date_insp, dd/MM/yyyy)</code> <br>where <em>date_insp</em> is the name of an attribute containing a date and <em>dd/MM/yyyy</em> is the desired date format, as indicated in the documentation of the <a href="http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html">java.text.SimpleDateFormat</a> Java class. <strong>Example</strong><br><code>format(attrib, ##0,00)</code> <br>where <em>attrib</em> is the name of an attribute containing a number and <em>##0,00</em> is the desired number format, as indicated in the documentation of the <a href="https://docs.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html">java.text.DecimalFormat</a> Java class.</td></tr><tr><td><strong>ifNull</strong>(<em>attrib</em>, <em>value</em>)<br><em>attrib</em>: the name of the attribute to test <br><em>value</em>: the value to display if <em>attrib</em> is null</td><td>Replaced by the <em>value</em> value only if the value of the <em>attrib</em> attribute is null. <br>If the attribute value is not null, nothing is displayed. <br><strong>Example</strong><br><code>ifNull(temp, N/A)</code> <br>Displays N/A if the value of the <em>temp</em> attribute is null. <br><strong>Example</strong><br><code>ifNull(attrib_a, attrib_b)</code> <br>Displays the value of the <em>attrib_b</em> attribute if the value of the <em>attrib_a</em> attribute is null.</td></tr><tr><td><strong>ifNotNull</strong>(<em>attrib</em>, <em>value</em>)<br><em>attrib</em>: the name of the attribute to test <br><em>value</em>: the value to display if <em>attrib</em> is not null</td><td>Replaced by the value only if the value of the <em>attrib</em> attribute is not null. <br>If the attribute value is null, nothing is displayed. <br><strong>Example</strong><br><code>ifNotNull(land_value, $)</code> <br>Displays only if the value of <em>land_value</em> is not null.</td></tr><tr><td><strong>subString</strong>(<em>attrib</em>, <em>startIx</em>, <em>endIx</em>) <br><em>attrib</em>: the name of the attribute for which a part must be extracted.<br><em>startIx</em>: starting position in the character string.<br><em>endIx</em>: ending position in the character string.</td><td>Replaced by a portion of the value (as a character string) of the <em>attrib</em> attribute, between the <em>startIx</em> position and <em>endIx</em> position. <strong>Example</strong><br><code>subString(name, 0, 5)</code> <br>Replaced by the first five characters of the name attribute value. If this value is <em>Montreal</em>, the mouseover will display <em>Montr</em>.</td></tr><tr><td><strong>encode</strong>(<em>attrib</em>, <em>encoding</em>)<br><em>attrib</em>: the name of the attribute to code<br><em>encoding</em>: the name of the encoding</td><td>Replaced by the value of the <em>attrib</em> attribute once it is encoded with the specified character encoding (UTF-8, CP437, ISO 8859-1, etc). <br><strong>Example</strong><br><code>encode(name, UTF-8)</code> <br>Replaced by the value of the <em>name</em> attribute encoded in UTF-8 characters.</td></tr><tr><td>&#x3C;<strong>script</strong>> code <em>JavaScript</em>&#x3C;<strong>/script</strong>></td><td><p>Runs the <em>JavaScript</em> code found between the tags. <br>In <em>JavaScript</em>, the attribute values of the elements are accessible through the <code>elementValue()</code> or <code>ev()</code> function. <br>Mathematical operations or character string operations can be performed on attribute values. <br>To display content in the mouseover, the script must call on the <code>print()</code> function. <br><strong>Example</strong><br><code>&#x3C;script></code> </p><p><code>print ( ev(population) / ev(area) );</code> </p><p><code>&#x3C;/script></code> <br>Calculates and displays the result of the value of the <em>population</em> attribute divided by the value of the <em>area</em> attribute. <br><strong>Example</strong><br><code>&#x3C;script></code> </p><p><code>var KM_IN_MI = 0.621371;</code> <code>var dist_mi = ev(km) * KM_IN_MI;</code> </p><p><code>print('ev(osm_name)');</code> </p><p><code>print(dist_mi.toFixed(1) + " mi");</code> </p><p><code>&#x3C;/script></code><br>Converts the distance in kilometers contained in the value of the <em>km</em> attribute into miles. Displays the value of the <em>osm_name</em> attribute and the distance in miles with a decimal figure.</p></td></tr><tr><td>&#x3C;<strong>a href="download:</strong>file URL<strong>"</strong>><em>some text</em>&#x3C;<strong>/a</strong>></td><td>JMap supports a special hyperlink syntax that allows a user to download a file by clicking on the link. <br>The file to download can come from a <em>http:</em> or a <em>file:</em> URL. <br><strong>Example</strong><br><code>&#x3C;a href="download:http://someserver/123/report.pdf">Download&#x3C;/a></code> <br>Displays a link that can be used to download the <em>report.pdf</em> file from the web. <br><strong>Example</strong><br><code>&#x3C;a href="download:file://D:/123/report.pdf">Download&#x3C;/a></code> <br>Displays a link that can be used to download the <em>report.pdf</em> file from a Windows file system folder.</td></tr><tr><td><strong>photosAsThumbnails</strong>()</td><td>Replaced by smaller versions of the images attached to the element. <br>The user can click on a thumbnail to open the full size image. <code>photosAsThumbnails(title)</code> <code>photosAsThumbnails(date)</code> <code>photosAsThumbnails(title,date)</code> <br>With these options, the title and/or date will be displayed with each thumbnail. <br><strong>It is very important that you do not add any spaces between </strong><em><strong>title</strong></em><strong>, the comma, and </strong><em><strong>date</strong></em>.</td></tr><tr><td><strong>projectName</strong>()</td><td>Replaced by the name of the current project.</td></tr><tr><td><strong>userName</strong>()</td><td>Replaced by the user code of the user that is currently connected.</td></tr><tr><td><strong>sessionId</strong>()</td><td>Replaced by the identifier of the current session.</td></tr><tr><td><strong>host</strong>()</td><td>Replaced by the name of the host or address of the JMap Server instance to which the application is connected.</td></tr><tr><td><strong>port</strong>()</td><td>Replaced by the port number (http or direct) of the JMap Server instance to which the application is connected.</td></tr><tr><td><strong>date</strong>()</td><td>Replaced by the current date and time.</td></tr></tbody></table>

### **HTML tags**

The contents of the bubble can be formatted using simple HTML tags. Mouseover bubbles do not support CSS or advanced tags such as `<DIV>`.&#x20;

The following HTML tags are supported and frequently used in mouseover bubbles:

`<B>, <I>, <U>, <A>, <IMG>, <BR>, <TABLE>`

You can insert hyperlinks in bubbles. These hyperlinks can be clicked, and they allow users to open HTML pages or to open or download files.

### **Examples**

<table data-header-hidden><thead><tr><th width="398"></th><th></th></tr></thead><tbody><tr><td><code>City : ev(CITY)</code> <br>A simple example of static text with the value of an attribute.</td><td><img src="https://content.gitbook.com/content/DUF1p2rT0hfE3QBlbbvE/blobs/PqCaqC5r8K8qcCtV4aL0/mouseover_2_en.png" alt="" data-size="original"></td></tr><tr><td><code>City: ev(CITY)</code> <br><code>(ev(COUNTRY))</code> <br>Example containing static parts and displaying 2 attribute values on 2 lines.</td><td><img src="https://content.gitbook.com/content/DUF1p2rT0hfE3QBlbbvE/blobs/KjrRFcg8RoSUvww7LWkU/mouseover_3_en.png" alt="" data-size="original"></td></tr><tr><td><code>&#x3C;b>ev(STATION_NAME)&#x3C;/b></code><br><code>&#x3C;a href="ev(URL)">Site web&#x3C;/a></code> <br>An example of basic formatting using HTML tags and a hyperlink where the URL comes from the value of the URL attribute.</td><td><img src="https://content.gitbook.com/content/DUF1p2rT0hfE3QBlbbvE/blobs/LM0CrS0uoKjlfUZWpPFW/mouseover_4_fr.png" alt="" data-size="original"></td></tr><tr><td><code>&#x3C;b>ev(DESCRIPTION)&#x3C;/b></code> <br><code>&#x3C;img src="ev(IMAGE_URL)" height="175" width="234" /></code> <br>An example of an HTML tag that takes the image URL from the value of the IMAGE_URL attribute.</td><td><img src="https://content.gitbook.com/content/DUF1p2rT0hfE3QBlbbvE/blobs/DhFlh0xKmlkCSmeS5W8Z/clip0001.tiff" alt="" data-size="original"></td></tr><tr><td><code>Area :</code> <br><code>ev(AREA_KM2) km2</code> <br><code>&#x3C;script></code> <br><code>var SQ_KM_IN_SQ_MI = 2.58998811;</code> <br><code>var area_sq_mi = ev(AREA_KM2) / SQ_KM_IN_SQ_MI;</code> <code>print(area_sq_mi.toFixed(1) + " sq. mi");</code> <br><code>&#x3C;/script></code> <br>An example of a <code>&#x3C;script></code> tag with JavaScript code. The value of the AREA_KM2 attribute is converted from square kilometers to square miles.</td><td><img src="https://content.gitbook.com/content/DUF1p2rT0hfE3QBlbbvE/blobs/pBBUhKT29Ki01CQIqH7k/clip0042.png" alt="" data-size="original"></td></tr><tr><td><code>&#x3C;table style="border:3px solid black; border-radius:5px; background: #1fc8db; color:white"></code> <code>&#x3C;thead></code> <br><code>&#x3C;tr> &#x3C;th class="">Name&#x3C;/th> &#x3C;th class="actions">FirstName&#x3C;/th> &#x3C;/tr> &#x3C;/thead></code> <br><code>&#x3C;tbody></code> <br><code>&#x3C;tr> &#x3C;td class="">Gratton&#x3C;/td></code> <br><code>&#x3C;td class="actions">Bob&#x3C;/td> &#x3C;/tr> &#x3C;/tbody></code> <br><code>&#x3C;/table></code> <br>An example of formatting with a style attribute.</td><td><img src="https://content.gitbook.com/content/DUF1p2rT0hfE3QBlbbvE/blobs/JODK6ol0bBsPzbFhbWMd/clip0076.png" alt="" data-size="original"></td></tr></tbody></table>

## Locating map elements or coordinates using mouseover

Mouseover supports a function to locate map coordinates or elements using a special URL syntax. A hyperlink is displayed in the bubble, and when it is clicked, the map locates the specified element(s) or region.

| `<a href="locate:region;-73;45;5;5">Locate</a>`                          | <p>Displays a <em>Locate</em> hyperlink. <br>When clicked, locates the region defined by x=-73, y = 45, width = 5, height = 5 in the same map. This is expressed in the map's units.</p>                                                                                                                                                                                          |
| ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<a href="locate:object;subway;name;'atwater'">Locate</a>`               | <p>Displays a <em>Locate</em> hyperlink. <br>When clicked, locates the elements on the subway layer that have their attribute name equal to atwater in the same map.</p>                                                                                                                                                                                                          |
| `<a href="locate:object;subway;name;'a%'">Locate</a>`                    | <p>Displays a <em>Locate</em> hyperlink. <br>When clicked, locates the elements on the subway layer that have their attribute name starting with letter a in the same map.</p>                                                                                                                                                                                                    |
| `<a href="locate:object;subway;name;'atwater';1000">Locate</a>`          | <p>Displays a <em>Locate</em> hyperlink. <br>When clicked, locates the elements on the subway layer that have their attribute name equal to atwater in the same map. <br>The resulting map has a scale of 1 : 1000.</p>                                                                                                                                                           |
| `<a href="locate:object;subway;name;'atwater':target=Result">Locate</a>` | <p>Displays a <em>Locate</em> hyperlink. <br>When clicked, locates, in a new map called <em>Result</em>, the elements on the subway layer that have their attribute name equal to atwater. <br>If a map called <em>Result</em> already exists, it is reused. <br>If the name of the map was new, a new map (with an automatically generated name) would be created each time.</p> |

## Using a URL to display content

You can specify a URL that opens an HTML page to display in the mouseover bubble (only supported in JMap Pro). The HTML page will occupy 100% of the bubble. The syntax is as follows:

`$URL{http://awebsite.com}`

The specified URL can be static or it can come from an attribute. It can also use attribute values as parameters, as shown below:

`$URL{http://awebsite.com?param1=ev(ATTRIB_A)&param2=ev(ATTRIB_B)}`

<figure><img src="https://content.gitbook.com/content/DUF1p2rT0hfE3QBlbbvE/blobs/4j9eO4bx0AgcYhtE0BeP/mouseover_5_fr.png" alt=""><figcaption></figcaption></figure>
