Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Brian_Munz
Employee
Employee

Open Source Geospatial Mapping Extension using KML files

A little while back, I posted a few mapping extensions that read in various kinds of data to allow mapping of regions and data on Google Maps.  One major problem with those is that Google is now charging money for useof their mapping product, so in order to use this extension on any grand scale,they'd need to purchase licensing.

So, in response to this, I've built an extension which uses all open source (free) products to provide some similar mapping capabilities(and then some).  The tool which provides the scrolling and "slippy" map features is called OpenLayers which reads in map imagery from OpenStreetMap. What I've done this time, however, is built the extension to read in KML files for the regions.  KML is a format that is very common in the industry (Google Earth uses and creates the files) ,and there are many tools out there to convert other formats (like shape files) into the KML format.

So, for example, I went and found a KML file for the US 50 states and put it into this new extension, and was able to create a map similar to my other US Map extension:

map_shot.png

New Features


Above and beyond the normal features of the extensions I created for Google, this extension provides a few new features:

  • No more setting the zoom and center point - In the other extensions, you had to set the default center point of the map as well as how far in it should be zoomed when it loads.  In order to make the map more user friendly and intuitive, this extension automatically determines the center point of all of the regions and sets the window to show the whole map.  This way, also, if you click on a region, the map window will only show the selected region:
    one_state.png
  • Select Box -With this extension, if you hold down the shift key and drag an area with your mouse, a select box will appear, allowing you to select many regions at once:
    select_box.png
    Once the selection is made, the window will adjust itself to only show that region:chosen.png
  • Loading KML files - Loading KML files into the extension eliminates a lot of the manual work that was need for the other extensions.  This way, as long as the KML names and QlikView dimension match up, KML files containing any kinds of regions can be used.  So, for example, if a company has custom regions representing different sales regions, etc. in a KML file, it would be very easy to plug it into this extension.

  • It's free- It uses open source technology so nobody will have to worry about licensing or being chased down by Google.

I've attached the extension as well as a QVW and quick guide.  In the extension is a sample KML file called us_states.kml that can be used with the example QVW.

Please let me know if you have any questions.  Hopefully this is useful to people.

UPDATE

Due to some issues with versions of Internet Explorer prior to 9 and how it handles different data formats, it is now necessary to change the KML file into an XML file prior to loading it into the extension.  So, for example, if you have a KML named "counties.kml" you need to change the file extension so it becomes "counties.xml".  Hopefully I'll eventually get time so this last step can be avoided, but for now it's necessary in order for the extension to work in IE8.

I've updated the attatchments on this post to use an XML file, so the examples should now work.

176 Replies
Not applicable

Hi Everyone,

It's a great extension! I am also on QV11 SR1 with IE8. I followed the user's guide and I can show the map in qlikview. However, it can't make the data connected to the map. There no color shows on my map. Also, the color expression column doesn't work for me. Whenever I entered a value in it, it did store the value that I entered. Is there anything that I do wrong? Thanks!

Kevin

Anonymous
Not applicable

Hi All,

Firstly, thanks Brian for your great work. When I first saw this extension I thought it might be the answer to a particular requirement I have but I couldn't get it to work. I'm pretty new to QlikView and had only a simplistic understanding of the geo side of things, so it's been quite the educational journey working out what was going on.  I thought a couple of things I've learnt might help others who have had similar problems to myself (despite my kml files displaying fine in google earth etc they wouldn't display in the extension):

1. The extension forces all your region names to upper case, so your data needs to be as well

2. The extension doesn't handle the circumstance where you have multiple polygons for the one "name", i.e., what is referred to as a geometry.  An easy way to see if your kml file has geometries is to load it into a kml editor such as NorthGates KML Builder.

thomaswrieck
Partner - Creator
Partner - Creator

Hi Brian,

great extension ! Just a quick question .. in QV 10 SR4 I can add formulas as needed but in QV 11 SR1 I'm missing this option.

Map.JPG

Do I miss something here ?

Best regards

Thomas

Alexander_Thor
Employee
Employee

Hi Thomas,

If I'm not misstaken I think there is a bug in SR1 currently that generates a faulty dynprop file for you.

This is a quote from a post a bit back in the thread,

"Hi Pranita, it's a bug og QV11 SR1 when create a dynamic Properies file.

To solve it you need to create a new Properties no dynamic.

1) In the definition.xml you have insert this row:

          <PropertiesPage Version="11" File="Properties.qvpp" />

2) rename DynProperties.qvpp in Properties.qvpp

3) open Properties.qvpp and change :

<div class='prop-grid_span-7 prop-grid_last' style='width:94%;' avq='prop_editexpression:.Chart.Expression.0.1.Definition'></div>

with

<div class='prop-grid_span-7 prop-grid_last' style='width:94%;' avq='prop_editexpression:.Chart.Expression.1.0.Definition'></div>"

thomaswrieck
Partner - Creator
Partner - Creator

Hi Alexander,

I tried this but that doesn't fix the issue with adding expressions ... the only effect is that the properties menu is not usable in QV 10 (SR4).

Any other hint ?

Thanks a lot ...

Thomas

cesaraccardi
Specialist
Specialist

Hi all, is it possible to export the map to an image file?

Thanks in Advance,
Cesar

Not applicable

I'm experiencing the same problem that was mentioned in previous posts:

WHERE CAN I FIND THE [US States.txt] FILE?????

DO I NEED IT TO RUN THE EXAMPLE?

THANKS!

"Cannot open file 'D:\Inst.dsk\Develop\QlikView\Extensions\openlayers\US States.txt' The system cannot find the file specified.

LOAD

    RIGHT(TRIM(@1:n), 2) as State,

    TRIM(@1:n) as Data

FROM

[US States.txt]

(fix, codepage is 1252)"

Not applicable

Are you using personal or server edition? I beliveve the personal edition removes the data on the recovery process.

I had the same issue and to resolve I created my own data file and loaded using an altered script

LOAD @2 as StateName,

     @1 as State,

     Round(Rand(), 0.01) * 100 as Num

FROM

[US States.txt]

(txt, codepage is 1252, no labels, delimiter is ',', msq);

Not applicable

Hy gandelr and Alexander,

I´m running QV11 SR1, and had the same problem with "color expression", After applying exactly your suggestions, it began to run. Thanks a lot!

Daniel

jlcsantos
Contributor
Contributor

On script.js change :

    if ((row[2].text != "") && (row[2].text != "-")) {

                    thisC = colorFormatter(row[2].text);

    }

    else {

                    thisC = fC;

    }

to :

    if ((row[2].text != "") && (row[2].text != "-")) {

                    var temp = row[2].text

                    var parte = temp.split(",");

                    if (parte[0] === "ARGB(255") {

                              temp = "RGB("+parte[1]+","+parte[2]+","+parte[3];

                    }

                    thisC = colorFormatter(temp);

    }

    else {

       thisC = fC;

    }