1 2 3 Previous Next 175 Replies Latest reply: Jan 12, 2017 8:57 PM by Ronald Van Moere RSS

    Open Source Geospatial Mapping Extension using KML files

    Brian Munz

      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:


      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:
      • 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:
        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.



      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.

        • 1. Open Source Geospatial Mapping Extension using KML files

          Very nice Brian! Keep up the great work!


          I've been looking into my problem of manipulating a map when using the QV desktop client without webview. As far as I know, the only solution is to manipulate a background image with the URL that gets the image. For google there exists such a thing to draw area's and lines and markers... But offcourse I need to draw alot of them. The URL is limited to 2000 characters and even when encoded, the paths I use would be too long.


          Therefor I was thinking of my own webservice that generates a map out of some shape files I have lying arround here. It's not the best solutions (you would not be able to interact with the lines drawn) but untill qliktech finally realises that their product is running behind the competition concerning mapping of data, it's the closest I'll likely come to BI on maps... Or I should change the software...


          If anybody knows how to start on the mapping service, feel free to drop a hint ;-)

          • 2. Open Source Geospatial Mapping Extension using KML files
            Brian Munz

            FYI, I heard from several people there was an issue with the map in Internet Explorer 8.  So, in order to avoid this issue, there is one more step you need to do when setting up this extension.  Rather than simply loading a KML, you need to change the file name to an XML file.  Please see above. 

            I've also changed the sample documents that are attatched to this post, so everything should work now.

            I hope to get it working in the future without this final step, but for now, it should allow you to use it.

            • 3. Open Source Geospatial Mapping Extension using KML files
              Rob Wunderlich

              Hi Brian,


              This looks great! But I'm having some trouble getting it to work. I've tried under both QV10 and QV11. On initial open, the object is blank. If I zoom in I get some map, which I can slip around and continue to zoom. Big issue is that I never get any coloring.


              As a debug exercise, I commented out in script.js:

              //window.onerror = silentErrorHandler;


              and got this error when I opened the qvw.


              An error has occurred in the script on this page.

              Line:  512

              Char: 237

              Error: 'null' is null or not an object

              Code: 0

              URL: http://www.openlayers.org/api/OpenLayers.js



              Any suggestions or request for additional details?




              • 4. Re: Open Source Geospatial Mapping Extension using KML files
                Brian Munz

                Hi Rob,

                When did you download the extension?  I just updated it a few days ago. If you downloaded it today, which version of IE are you running?  Also, I haven't had a chance to test this extension in QV 10.


                • 5. Open Source Geospatial Mapping Extension using KML files
                  Rob Wunderlich

                  Hi Brian,


                  I downloaded the file on 13 Jan. I downloaded today and retested with the same negative results. I'm running IE8.




                  • 6. Open Source Geospatial Mapping Extension using KML files

                    Very interesting extension Brian.

                    Using maps in a better way than the known "Gmaps + scatter chart" method and also being free, is really useful for a lot of people. I also find pretty interesting the things that can be done with the openlayers API (see http://openlayers.org/dev/examples/).


                    I tested the "first" version, and could get it to work (had to update to IE9). Also did a test with another maps and worked, but for the moment, depending on the KML, if the region has two polygons only one may appear.


                    Tuning the KML I could get something like shown in the picture (Cataluña region in Spain).ScreenShot187.png


                    Kind Regards,



                    • 7. Open Source Geospatial Mapping Extension using KML files
                      Brian Munz

                      Looks good.  Yes the KML has to be in a particular format.  Looking at the US_States.kml file in the extension's folder is a good way to see the proper formatting.  The name of the region should be set in the <name> tags and needs to match the region dimension being set in the properties box.  Also, if a region has multiple polygons, they'll all be set up as long as they're set up under the same placemark.

                      Again, taking a look at the KML itself should help.

                      I'm also planning on getting this extension to work with plot points as well as polygons soon, so it can be more flexible and versatile.

                      • 8. Re: Open Source Geospatial Mapping Extension using KML files

                        Hi Brian,

                        I downloaded your extension but it seems like there is something not working for me (on QV 10SR4).




                        And actually it looks like there is something wrong with the properties of the object (judging from the guide you included):




                        I am not able to edit the properties like "KML Filename" and the map doesn't load at all anyway.

                        Is there any other setting I should be looking for?


                        Thank you

                        • 9. Re: Open Source Geospatial Mapping Extension using KML files
                          Brian Munz

                          Unfortunately I haven't been able to test  this extension on versions of QlikView earlier than 11 yet. I hope to find some time soon to do so.

                          • 10. Re: Open Source Geospatial Mapping Extension using KML files


                            I didn't notice you had remarked that already.


                            I'm updating IE and QV and giving it a try.

                            Btw, I tried to add some more layers to your example but it seems like I can't add any new buttons to the controls (the layer wasn't showing anyway but it could be IE8)


                            Have you got any hints?




                            P.S.: IE 9 works like a charm.


                            Messaggio modificato da Francesco Menin

                            • 11. Re: Open Source Geospatial Mapping Extension using KML files

                              I've been trying to use a different XML file to get data into the map.


                              It seems like I can't get past the


                                          if ($.isEmptyObject(kmlJSON)) {


                                                  url: KMLFile,

                                                  type: "GET",

                                                  success: function(data){


                              point in the script.js... I tried to change the SetItUp() function to reflect my XML fields but it seems like there is no particular set working.


                              Is there a particular file format I need?




                              Is it possible that the kmlJSON object doesn't get empty on refresh?



                              • 12. Re: Open Source Geospatial Mapping Extension using KML files
                                Brian Munz

                                This particular extension needs to have the data in kml format.

                                • 13. Re: Open Source Geospatial Mapping Extension using KML files

                                  Thanks for a great extension.


                                  I’m trying to get it to work with colormix1() but it returns a ARGB value. And with my basic QV skills I don’t know how to convert it t oRGB. Is there a way to convert or use ARGB to get gradient colors?


                                  Btw whereis the donate button


                                  • 14. Re: Open Source Geospatial Mapping Extension using KML files

                                    Hi Brian,

                                    I'm sorry I didn't make myself clear


                                    I actually created a KML file but it seems to me that the



                                                        url: KMLFile,

                                                        type: "GET",

                                                        success: function(data){


                                    won't load my file. I actually copied your function in a new one to collect my data in a different Layer so I could try and change different properties. I can tell that I can't get to this point because I tried moving the


                                    var layerVector = new OpenLayers.Layer.Vector( "KML" );


                                    part right after the start of the if() and before the $.ajax request. My KML file is in the same place as is yours so I'm wondering what could be stopping it from getting the data.





                                    1 2 3 Previous Next