Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamic Maps

Hello

I am trying to solve a complex problem in QlikView using maps.

Background:

In my data set that is a single excel data file I have 6 data feilds with following names - Lat1, Long1, Lat2, Long2, Lat3, Long3

These data columns contain latitude and longitude in them.

I have other three data fields Opt1, Opt2, Opt 3 (Option data fields) which contains values 1 or 0

Data:

So the data looks like this in my excel sheet:

Opt1Lat1Long1Opt2Lat2long2Opt3Lat3Long3
155-1.522816145-1.5342046-1.6788
060

-1.513281

135-1.5782023-1.7234
165

-1.465094

025-1.5834145-1.8654
170-1.465453051-1.5888169-1.5761

QlikView Objects: Now I need to have a UK map in Qlikview and a drop down box that contains option - Option1, Option2, Option3.

Action:

  • When I select Option1 from the drop down list then the map should show only the Lat1 and Long1 locations on the UK map that have Opt1 value equal 1.
  • When I select Option2 from the drop down list then the map should show only the Lat2 and Long2 locations on the UK map that have Opt2 value equal 1.
  • When I select Option3 from the drop down list then the map should show only the Lat3 and Long3 locations on the UK map that have Opt3 value equal 1.

**I tried to use the google maps but I need to have some key and when I search for that key the google web page says that they are not available**

Kindly help, If you need more info please let me know. I will provide more details.


1 Solution

Accepted Solutions
Siva_Sankar
Master II
Master II

Asheoran, Received your mail. Attaching the qvw for you to get an idea.Also am attaching an excel sheet where you can use the tables individually and concatenate in the script to achive the solution. This may help. Regards. Siva

View solution in original post

14 Replies
Anonymous
Not applicable
Author

Setting aside the google maps (you'll find many working solutions here), here is you can do.
Create a variable "Option" which can have only one of three values, Opt1, Opt2, Opt3.  Use input box with drop-down.
Your expressions in maps will be using latitude and longitude:
.... lat... long ...

Replace with conditional in all expressions:
... pick(match(Option, 'Opt1','Opt2','Opt3'), lat1,lat2,lat3)...pick(match(Option, 'Opt1','Opt2','Opt3'), long1,long2,long3)

Regards,
Michael

Not applicable
Author

Hello Michael

Thank you for your reply.

I got this white paper from QlikView website that talks about using Google maps in QlikView but it seems this approach will not work as I need a Key from Google which they have removed.

In addition can you elaborate the solution suggested by you in more details as I am new to QlikView.

What expression will exactly go in the expression section of the map.

Anonymous
Not applicable
Author

That's correct, the key has been removed.  You need to make changes in two places:

1. Instead of "http://maps.google.com/staticmap?" use "http://maps.googleapis.com/maps/api/staticmap"

2. instead of "key='&gmap_key" use "sensor=false"

Regards,

Michael

Not applicable
Author

Hi Michael

Are you sure that the expression you suggested me will work as I think that google maps can only have one column for longitude and latitude in order to display.

Can you explain more about the expression as I am no able to understand it.

Anonymous
Not applicable
Author

There is a ton of info about google maps on this forum.  Here is one:

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

and, you can find a lot more.  But make sure to implement the change I mentioned above.

Regards,

Michael

Not applicable
Author

Hi Michael

Can you give me the exact expression that will go in the expression box as the expression you mentioned has got some dots.

Asheoran

Anonymous
Not applicable
Author

Not sure it will help you because there are varuiables here, and I don't know if you have them, and the field names can be different.

1st expression

= avg( round (256*pow(2,($(var_zoom)-1)))+( longitude  *((256*pow(2,$(var_zoom)))/360)) )

2nd expression

=avg(((256*pow(2,($(var_zoom)-1)))+((0.5*log((1+(sin((latitude)*pi()/180)))/(1-(sin((latitude)*pi()/180)))))*((-256*pow(2,$(var_zoom)))/(2*pi())))))

3rd expression is for the bubble size, whatever you use there.

And, the dynamic image expression on the colors tab:

='http://maps.googleapis.com/maps/api/staticmap?center='
& num(var_mid_lat, '##############', '.', ',' )
& ','
&
num(var_mid_long, '##############', '.', ',' )
& '&zoom=$(var_zoom)'
& '&size='&
map_size_x&'x'&map_size_y
&
'&sensor=false'
& '&maptype='&
var_maptype

Siva_Sankar
Master II
Master II

Asheoran, Received your mail. Attaching the qvw for you to get an idea.Also am attaching an excel sheet where you can use the tables individually and concatenate in the script to achive the solution. This may help. Regards. Siva

Not applicable
Author

Hi Siva

Thanks a lot for helping thats really helpful of you.

Intially it was the data model that was creating trouble and was making everything complex. So I changed the data model and now it look like this.

Scenario_NumberScenario_DetailLatitude1Longitude1
1152.42819-1.522816
1152.404266-1.513281
10NN
2154.534146-1.671421
2153.542385-0.721348
20NN
3153.010782-1.064692
3152.297214-0.834626
30NN

As compared to earlier in this data model I have replaced the Opt1,Opt2,Opt3,Opt4,... with one single column with name Scenario_Number and added another column with name Scenario_Detail which can only have 0s or 1s as value.

For a specific Scenario_Number, Scenario_Detail values tell which Latitude and Longitude should be displayed on map (when the value is 1 then that latitude & longitude should be displayed)


And all the Lat's and Long's are stored in just two columns - Latitude1 and Longitutde1 (If you look at the data set that I have attached with this post things will be more clear).

Now we can have a listbox/multibox via which we can select a Scenario_Number and corresponding values of Latitude1 & Longitude1 should be displayed.

I do not need to display any other dimention such as population etc.

So I worked on the the QlikView file that you gave me and loaded the data and changed few things in the script but its still not working.

Can you tell me where I am going wrong?