Displaying highlighted routes, pushpins, user-created data and other auxiliary data

CartoType applications that do navigation or route-finding need to highlight the current route, display points of interest and addresses selected by the user, and draw other temporary, fast-changing or custom data.

You can do this in a completely flexible way using an auxiliary map database supplied to CartoType at map drawing time. For example, to highlight a route, you could create a memory-resident map database (using the class CMemoryMapDataBase), add the layer "route" to it, and arrange for this database to contain one or more line objects representing the current route, if any.

You then add a layer section for the "route" layer to the style sheet, in a convenient place: probably after all other ordinary layers but before <labelLayer/>.

When a map is drawn and an auxiliary database is supplied as well as the main database, for every layer in the style sheet both databases are searched for matching objects. Objects from the main database are drawn first, then objects from the auxiliary database.

Because of this ordering, if you want to display highlighted icons that override icons from the main database, it is necessary to create a separate layer for the highlighted icons and place its <layer> section before the section referring to the main database, so that the highlighted icons are displayed first. Because of the rule preventing icons from overlapping, the icons for objects in the main database will not appear.

Here is a sample layer for highlighted routes:

<layer name="route">
<line width="18m,3pt" fill="teal" opacity="0.9"/>

Style Sheets Directory