Custom labels and dynamic symbols in Qlik GeoAnalytics using data URIs

    In the current version of Qlik GeoAnalytics there are limitations in the styling of labels and storage location of symbols to the bubble layer. Using data URIs with inline image files of PNG or SVG is neat workaround that works fine. The inline SVG can be produced on the fly with a Qlik expression which opens up a lot of possibilities, some use cases listed below. There are also some caveats which are listed in the end together with links to more information.




    Tip! Test the data URI directly in the browser, paste the URI in the browser (won't work in IE) bar



    Data URIs must be in either in Base64 encoding or URL safe ANSI ASCII. Since Qlik don't have URL or Base64 encoding built in we can use translation tables, online tools or for instance Notepad++ to do the conversion. Base64 is suitable for images and content that don't need to change dynamically. URL encoding is good for dynamic SVG where we want to change the appearance of the icon or the symbol with Qlik expressions. Options:

    1. Base64 conversion with external tool
    2. URL encode with external tool
    3. URL encode with translation table
    4. URL encode with expression
    5. Or to combine 2,3 and 4

    (3) Translation table example, useful for conversion of static content at load time. Here's an example with Western symbols, other tables can be found for other character sets. Note the use of MapSubstring.



    Mapping LOAD 

         Replace([Character], 'space', ' ') as ASCII_Character,

         Text([From UTF-8]) as URL_encoding 



    (html, utf8, embedded labels, table is @1);

    // Sites addresses


    Load *,

    MapSubstring('URL_Encoding_Reference', address) as encoded_address;






    FROM [lib://AssaAbloy/sites.csv]

    (txt, utf8, embedded labels, delimiter is ';');


    (4) Translation expression, note that it's not complete, it's a list common symbols, useful for translations in runtime. More symbols needs to be escaped to become URL safe, especially when working with UTF-8 characters.


    set v_uuenc =



    ,'%', '%25')

    ,' ', '%20')

    ,'#', '%23')

    ,'{', '%7B')

    ,'}', '%7D')

    ,'<', '%3C')

    ,'>', '%3E')

    ,'&', '%26')

    ,'|', '%7C')

    ,'[', '%5B')

    ,']', '%5D')

    ,'^', '%5E')

    ,'`', '%60')

    ,';', '%3B')

    ,'?', '%3F')

    ,':', '%3A')

    ,'@', '%40')

    ,'=', '%3D')



    Storing images in the app

    The bubble layer requires all symbols to be reachable by URL from the map server. But a data URI can be used instead, use an external tool to do the conversion. After that store the data URI in a string and place in the 'Image URL' in the bubble layer properties.



    Styling labels

    Labels has fixed font, size and color in QGA, a SVG symbol with text can be used to overcome that.

    • In SVG standard coordinate system y axis is point downwards.
    • The bubble layer centers the symbol on the point location.
    • SVG uses CSS colors.
    • Font type, weight and size can be specified.

    Here's an SVG that set font and color and size for a single row label:


    data:image/svg+xml,<svg xmlns="" height="200" width="200"><text text-anchor="start" font-family="Verdana" font-weight="700" font-size="14" fill="red"><tspan x="102" y="130">Red Label</tspan></text></svg>


    (Guides and border added for clarity)


    When properly URL safe encoded and put in QV expression the data URI looks like this, note how the label text is inserted in to the expression. The URL encoding was done with Notepad++ and the MIME tool plugin, there are also online encoders.




    ='data:image/svg+xml,' &

    encode(airport_Name) &



    Multi line labels

    Similar as the previous example, but with two rows in the label:


    data:image/svg+xml,<svg xmlns="" height="200" width="400"><text text-anchor="start" font-family="Verdana" font-weight="700" font-size="14" fill="blue"><tspan x="202" y="120">Label 1</tspan><tspan x="202" y="140">Label 2</tspan></text></svg>



    Data URI

    • All characters must be URL safe. All characters must be in ANSI ASCII
    • Make the custom symbol label an additional point layer, non-selectable.


    Links to more information and useful resources



    Example app with inline SVG, PNG and multiline, styled labels below: