Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using Dynamic Image in Qlikview scatter chart to link to Openstreetmaps

Hi everyone

Im currently trying to display a map in QV that is a bit more dynamic than just using an image for the map with the scatter.

Im trying to get the dynamic image to work since i assume this will sort out my issue.Ive found a few examples and one of them uses the dynamic image linking to openstreetmaps but no image was loaded in that. I took this to mean that maybe web address syntax had been changed so went about testing what the URL should be.

eg ='http://www.openstreetmap.org/?lat=-29.871654510498&lon=30.9685707092285&zoom=13'

Even using just this address in dynamic image wont load the map.

To fulfill the dynamic aspect i did try and replace dynamic parts with variable numbers

eg.='http://www.openstreetmap.org/?lat=' & avg(num(LATITUDE,'############')) & '&lon=' & avg(num(LONGITUDE,'############')) & '&zoom=' & 11

Neither loaded anything

Any help or ideas would be great!

Thanks

5 Replies
Not applicable
Author

Brian

I looked at using this but found that the map load time was a shade on the slow side. We have shelved this for the moment as we also don't want to expose our QV server to the web.

If your apps are public facing then your best option would be to use the Google map tile server as it is far faster than the openstreetmap public servers, but I'm assuming that you have decided not to use them because of their licensing costs.

The two tile server I looked at were cloudmade and pafciu. They both have terms of use so worth checking their web sites for those. Pafciu is limited to the mapnik openstreetmap style whilst cloudmade offers a lot more variety.

The code I was using to set up a dynamic URL is below (just comment/uncomment the tile server you don't/do want to use):

var_maptype=    '=if(isnull(only(maptype)),fieldvalue('&chr(39)&'maptype'&chr(39)&', 1),maptype)';

// Cloudmade
var_styletype=  '=if(isnull(only(maptype)),fieldvalue('&chr(39)&'styletype'&chr(39)&', 1),styletype)';
var_map_url=    '='&chr(39)&'http://staticmaps.cloudmade.com/8ee2a50541944fb9bcedded5165f09d9/staticmap?center='&chr(39)&' & var_mid_lat & '&chr(39)&','&chr(39)&' & var_mid_long & '&chr(39)&'&zoom='&chr(39)&' & var_zoom & '&chr(39)&'&size='&chr(39)&' & map_size_x & '&chr(39)&'x'&chr(39)&' & map_size_y & '&chr(39)&'&format=jpg&'&chr(39)&' & var_styletype & '&chr(39)&'='&chr(39)&' & var_maptype'

maptype:
LOAD * INLINE [
maptype, styletype
Fresh, style
997, styleid
];


// OpenStreetMap (pafciu)
//var_map_url=    '='&chr(39)&'http://pafciu17.dev.openstreetmap.org/?module=map&lat='&chr(39)&' & var_mid_lat & '&chr(39)&'&lon='&chr(39)&' & var_mid_long & '&chr(39)&'&zoom='&chr(39)&' & var_zoom & '&chr(39)&'&width='&chr(39)&' & map_size_x & '&chr(39)&'&height='&chr(39)&' & map_size_y & '&chr(39)&'&imgType=jpg'&chr(39)

//maptype:
//LOAD * INLINE [
//maptype
//mapnik
//];

Best of Luck

David

Not applicable
Author

A quick follow-up on the above.

We have taken a lowish spec machine (single 2.67Ghz core, 2Gb ram and 120Gb disk space) and installed everything needed to run a OpenStreetMap tile server and static image generator. We have only imported the British Isles data from OpenSteetMap so the disk space we have is more than sufficient for what we need.

The speed gain over available internet based OSM static image servers is very noticable, and we no longer have the issue that we would have had to open our QV server to internet access.

You can build a mapserver from packages that are available, but due to our set up (20Gb system partition, 100Gb data partition, sitting behind a proxy server) the installation was far from simple (and not helped by the fact that I am, or was, a complete Linux novice). If you intend to set up your own map server the following pointers may be helpful:

  • Use a single partition on your server
  • Install of the latest Ubuntu Server (currently 12.1, but we went with 11.10) on the machine
  • Include a GUI in the install
  • Install webmin - a useful overview of your server and good for seeing your apache server
  • Install pgAdmin3 - if you end up having to complete the installation manually this is by far the easiest way to view the Postgre SQL database
  • For a command line client to connect from your pc to the server install a copy of PuTTY
  • For a GUI connection from your pc to the server install X2go (the client on your pc and the server part on your Ubuntu box)
  • Ensure that Subversion (SVN) is working correctly
  • If you are working behind a proxy ensure that the http_proxy environment variable is set up
  • You cannot successfully re-run the installer package if it fails - either set your server up again or complete the install manually
  • If you end up installing manually create a user account for www-data and install everything under that user name as the correct folder level access rights must be in place for the apache user account
  • If you are not taking mapping data for the whole planet, when you pre-render tiles ensure you use min/max x and y coordinates from at least zoom level 12 and up or what should take only a few hours will end up processing for days

The Switch2OSM site holds probably the best information on setting up a mapping server, either from packages or manually. When you get you installation working you will have a tile server capable of serving 256x256 map images, which can be used by slippy map applications.

To serve static map images you will also need to install software capable of taking those tiles and stitching them into a single image of the size you need. The best/easiest solution I found for this was StaticMapLite  and you can use SVN to obtain a copy of the code from SourceForge. You will then need to edit the staticmap.php file to change the url for the mapnik style to http://localhost/osm_tiles2/{Z}/{X}/{Y}.png assuming you have installed StaticMapLite on the same machine.

Assuming you use the above set up, and that you put the static map folder structure in yourwebroot/staticmap your url for use in QlikView will become

  

var_map_url = '='&chr(39)&'http://your.server.name/staticmap/staticmap.php?center='&chr(39)&' & var_mid_lat & '&chr(39)&','&chr(39)&' & var_mid_long & '&chr(39)&'&zoom='&chr(39)&' & var_zoom & '&chr(39)&'&size='&chr(39)&' & map_size_x & '&chr(39)&'x'&chr(39) &'& map_size_y'

If you are installing manually you do have other options instead of using OpenLayers to serve map images. Leaflet is one such option and the install process is described in a fair amount of detail on Switch2OSM.

The mapnik code is in the process of being rewritten. The package install should use version 0.7.2 but if you wanted to you could use the newer version 2.0. However, as quite a lot of the stylesheet structure changed between 0.7.2 and 2.0, you may want to wait for version 2.1 which reverts back to 0.7.2 naming conventions

rbecher
MVP
MVP

Hi Brian,

maybe you find my example "Open Street Map tiles as dynamic background" helpful:

http://community.qlik.com/docs/DOC-2874

- Ralf

Astrato.io Head of R&D
Not applicable
Author

Hi All,

Just wanted to share this:

http://www.wipfli.com/BlogPost_QT_BI_Blog_053111.aspx

Thanks Shawn

Pierre

Not applicable
Author

Hi David,

it's been some time but hopefully you can help me.

I would like to use my own tiles on a locahost just as you described.

On my windows machine I could get Apache server with PHP extension working, downloaded the staticmap.php and changed the adress to my localhost.

Everything seems to be fine but I can't get the static map working.

There must be something wrong but I can't figure it out.

Do you really need to use leaflet or switch2osm? I thought it should be enough to install Apache/PHP to have a server environment and use staticmap.php with localhost-setup. Did you change anything else in you staticmap.php or is it something else I am missing?

Thanks and best regards,

Chris