24 Replies Latest reply: Sep 4, 2014 6:20 AM by Ridhaa Hendricks RSS

    Google Maps API

    Juan Escobar

      Hello,

       

      I was looking some QV Dashboards and I found that I can insert a map with some information inside. How can I add this kind of object and associate the places with the information?

       

      If anyone has a demo or some code, please let me know.

       

      That will be great.

       

      Thank you very much.

        • Re: Google Maps API
          Sokkorn Cheav

          Hi Juan,

           

          To make this happen first you need coordinates (longitude / latitude)  for your location.

          See the sample attached file.

           

          Regards,

          Sokkorn

            • Google Maps API
              Juan Escobar

              Hi Sokkorn,

               

              I'm running at this time the Personal Edition so I can't open that example. I was looking at the table and I realized that I have to create something like that for Colombia.

               

              Now, which option allows me to insert the map as well and associate it with the table

               

              Thank you very much.

                • Re: Google Maps API
                  Sokkorn Cheav

                  Hi Juan,

                   

                  Let check my attached file again.

                   

                  Or try this

                  SET ThousandSep=',';
                  SET DecimalSep='.';
                  SET MoneyThousandSep=',';
                  SET MoneyDecimalSep='.';
                  SET MoneyFormat='$#,##0.00;($#,##0.00)';
                  SET TimeFormat='h:mm:ss TT';
                  SET DateFormat='M/D/YYYY';
                  SET TimestampFormat='M/D/YYYY h:mm:ss[.fff] TT';
                  SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';
                  SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';
                  //===========================================================
                  [Location]:
                  LOAD
                      RowNo()    AS ID,
                      Country, 
                      Locations, 
                      [Latitude-Degree], 
                      [Longitude-Degree], 
                      Latitude, 
                      Longitude
                  FROM
                  [Cambodia Latitude-Longitude v002.xlsx]
                  (ooxml, embedded labels, table is Sheet1);
                  //===========================================================
                  // Google Maps in QlikView
                  // V0.85.2 - October 1st 2008  © Copyright QlikTech International AB 2008 / AES
                  
                  // Google Maps Key
                  // get a key here http://code.google.com/apis/maps/signup.html
                  gmap_key = 'xx';
                  max_zoom_level = 17; //maximum value 17 
                  
                  // Variables required for calculating map
                  // No need to change these
                  var_pi180=        '=pi()/180';
                  var_lat_offset=    '0';
                  var_long_offset = '0' ;
                  var_mc2=        '=256*pow(2,$(var_zoom))';
                  var_mc1=        '=256*pow(2,($(var_zoom)-1))';
                  var_mid_lat=    '=min(Latitude)+(1+var_lat_offset)*((max(Latitude)-min(Latitude))/2)';
                  var_mid_long=    '=min(Longitude)+(max(Longitude)-min(Longitude))/2';
                  var_zoom=        '=max(aggr(if(max( round(256*pow(2,(_zoom_level -1)))+( Longitude  *((256*pow(2,_zoom_level ))/360)) )-min( round(256*pow(2,(_zoom_level -1)))+( Longitude  *((256*pow(2,_zoom_level ))/360)) ) <map_size_x AND max((256*pow(2,(_zoom_level-1)))+((0.5*log((1+(sin((Latitude)*pi()/180)))/(1-(sin((Latitude)*pi()/180)))))*((-256*pow(2,_zoom_level))/(2*pi()))))-min((256*pow(2,(_zoom_level-1)))+((0.5*log((1+(sin((Latitude)*pi()/180)))/(1-(sin((Latitude)*pi()/180)))))*((-256*pow(2,_zoom_level))/(2*pi()))))<map_size_y,_zoom_level,1),_zoom_level))';
                  var_maptype=    '=if(isnull(only(maptype)),fieldvalue( '& CHR(39)&'maptype'& CHR(39)&', 1 ),maptype)';
                  map_size_x=        '640';
                  map_size_y=     '400';
                  
                  SET HidePrefix='_' ;
                  // Field required for calcualting best zoom level
                  _zoom_level:
                  LOAD RecNo() AS _zoom_level AutoGenerate(max_zoom_level);
                  
                  maptype:
                  LOAD * INLINE [
                      maptype
                      roadmap
                      mobile
                      satellite
                      terrain
                      hybrid];
                  

                   

                  1. Create Scatter Chart
                      . Dimension
                          - ID
                      . Expression
                          -Label1: longitude with expression =sum( round (256*pow(2,($(var_zoom)-1)))+( Longitude  *((256*pow(2,$(var_zoom)))/360)) )
                          -Label2: lattitude with expression =sum(((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())))))
                          - Locations // Pop_up text (no label)
                  2. Create List Box: maptype
                  

                  Do let me know, if this one still cannot open the file.

                   

                  Regards,

                  Sokkorn

                • Re: Google Maps API
                  Agnivesh Kumar

                  plese sen QVS file for this qvw file.

                • Re: Google Maps API

                  Hi Juan,

                   

                  Could you solve your problem? I'm trying to create a map with Colombia coordinates, I'm using "Steps to Implement Google Map in Qlikview" in QlikView PE, but it didn't work. I didn't get any symbol on the map. Could you help me?

                  • Re: Google Maps API

                    Hi Juan,

                     

                    Thanks for the file but I have Personal Edition and I can't open files. Could you share your code or tell me what exactly changed for the map work?

                     

                    Best Regards.

                      • Re: Google Maps API

                        I am also having this problem.  I am followed the steps and this is what i get.  Can anyone help me? 

                        What did i do wrong?

                         

                        I cant seem to display google map. 

                        I had used the scripts above.

                        test.jpg

                          • Re: Google Maps API
                            Juan Escobar

                            In the Colors tab, look for the Frame Background. Now check Dynamic Image and in the expression paste this:

                             

                            ='http://maps.google.com/staticmap?center='

                            &

                            num(var_mid_lat, '##############', '.', ',' )

                            &

                            ','

                            &

                            num(var_mid_long, '##############', '.', ',' )

                            &

                            '&zoom=$(var_zoom)'

                            &

                            '&maptype='&var_maptype

                            &

                            '&size='&map_size_x&'x'&map_size_y

                            &

                            '&key='&gmap_key & '&.jpg'

                              • Re: Re: Google Maps API

                                Unfortunately still the same... Screenshot.jpg


                                I have attached my Qlikview file.  Hope you could enlighten me on how to do it step by step? as i will not be able to open your file since I am using the personal edition.


                                thanks much

                                  • Re: Re: Re: Google Maps API
                                    Juan Escobar

                                    In the Axes Tab, you have to modify the Static Min and Max.

                                     

                                    X-Axis:

                                    Static Min:

                                    (256 * pow(2,($(var_zoom)-1))) + ( var_mid_long * ((256 * pow(2,$(var_zoom))) / 360)) - Round(map_size_x/2)

                                     

                                    Static Max:

                                    ((256 * pow(2,($(var_zoom)-1))) + ( var_mid_long * ((256 * pow(2,$(var_zoom)))/360)) + Round(map_size_x/2)-15)

                                     

                                    Y-Axis:

                                    Static Min:

                                    ((256 * pow(2,($(var_zoom)-1))) + ((0.5 * log((1 + (sin(var_mid_lat * pi() / 180))) / (1 - (sin(var_mid_lat * pi() / 180))))) * ((-256 * pow(2,$(var_zoom))) / (2*pi()))) + Round(map_size_y/2))

                                     

                                    Static Max:

                                    =((256 * pow(2,($(var_zoom)-1))) + ((0.5 * log((1 + (sin(var_mid_lat*pi()/180))) / (1 - (sin(var_mid_lat * pi() / 180))))) * ((-256 * pow(2,$(var_zoom))) / (2 * pi()))) - round(map_size_y/2)+15)

                                     

                                    Also te gmap_key that you where using won't plot anything. I reatached, please reload and let me know.

                                  • Re: Google Maps API
                                    Andreas Warning

                                    I have changed the code in the example for the Dynamic Image and in the expression:

                                     

                                    ='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

                                    &

                                    '&maptype='&var_maptype

                                    &

                                    '&sensor=false'

                                    &

                                    '&key='&gmap_key &'

                                     

                                    It works very well. Thank you Sokkorn.