14 Replies Latest reply: Apr 22, 2013 5:26 AM by Abs Sheoran RSS

    Dynamic Maps

    Abs Sheoran

      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.

       


        • Re: Dynamic Maps
          Michael Solomovich

          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

          • Re: Dynamic Maps
            Abs Sheoran

            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

              • Re: Dynamic Maps
                Michael Solomovich

                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

                 

                 

                • Re: Dynamic Maps
                  sivasankar kanagasabai

                  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

                    • Re: Dynamic Maps
                      Abs Sheoran

                      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?

                  • Re: Dynamic Maps
                    Abs Sheoran

                    Hey Experts

                    You guys have been really helpful I was finally able to implement google maps in my QlikView document.

                    Now I am stuck on the map size. I tried to change it but was not able to.

                     

                    Can anyone tell me if there is anyway we can change the size of the map.