0 Replies Latest reply: May 1, 2017 4:08 PM by Neal Gosz RSS

    Issue with Google Map zoom

    Neal Gosz

      Hello,

       

      I have read numerous threads on Community on setting up a Google Map within Qlikview, which I had done previously.

       

      Our project has now been re-visited and when I try to generate the map with a new API key, the map just focuses on the entire globe, although the plots seem to point to the map locations I'd like.

       

      I have a Geocoded table that would join by Zip Code

       

       

      here's the map code:

       

      // number of seconds to wait for a URL datasource

      set OpenUrlTimeout=10;

       

      gmap_key = 'xxxxx';

      max_zoom_level = 14; //maximum value 17

       

       

      // Variables required for calculating map

      // No need to change these

      var_pi180= '=pi()/180';

      var_lat_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=    '600';

      map_size_y=     '400';

       

       

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

       

       

      vMinXaxis       = ' (256*pow(2,((var_zoom)-1)))+((var_mid_long)*((256*pow(2,(var_zoom)))/360))-(def_map_size*0.5)';

      vMaxXaxis = '((256*pow(2,((var_zoom)-1)))+((var_mid_long)*((256*pow(2,(var_zoom)))/360))+(def_map_size*0.5))';

      vMinYaxis = '((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())))+(def_map_size*0.5))';

      vMaxYaxis = '((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())))-(def_map_size*0.5))';

       

       

      SET HidePrefix='_' ;

      // Field required for calcualting best zoom level

      _zoom_level:

      Load RecNo( ) as _zoom_level autogenerate(max_zoom_level);

       

       

       

       

      //inline load for various map types

      maptype:

      LOAD * INLINE [

          maptype

          roadmap

        mobile

        satellite

        terrain

        hybrid

      ];

       

       

      The Dynamic Image in the Presentation tab is set to this:

      ='http://maps.googleapis.com/maps/api/staticmap?center=' & 

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

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

      '&zoom='& $(var_zoom) &

      '&maptype='& (var_maptype) &

      '&size=600x400' &

      '&sensor=false'

       

       

      with 0% Transparency

       

      Scale x-axis

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

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

       

      Scale y-axis

      ((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))

       

      Is there some adjustments in the map I'm missing that the map does not focus to the locations I'm setting the slider bar to?

      Error.PNG

       

      Thanks in advance

      Neal