2

I'm trying to create google map in QlikView for dashboard creation. The version of QlikView I use is 12.10. I use the following code for main:

SET ThousandSep=',';
SET DecimalSep='.';
SET MoneyThousandSep=',';
SET MoneyDecimalSep='.';
SET MoneyFormat='$#,##0.00;($#,##0.00)';
SET DateFormat='M/D/YYYY';
SET TimestampFormat='M/D/YYYY h:mm:ss[.fff] TT';
SET FirstWeekDay=6;
SET BrokenWeeks=1;
SET ReferenceDay=0;
SET FirstMonthOfYear=1;
SET CollationLocale='en-US';
SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';
SET LongMonthNames='January;February;March;April;May;June;July;August;September;October;November;December';
 SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';
SET LongDayNames='Monday;Tuesday;Wednesday;Thursday;Friday;Saturday;Sunday';

CustomerTable:
LOAD Quantity, Customer, City
FROM [C:\Users\540195\Downloads\Customer_info.xls] (biff, embedded labels, table is Sheet1$);

let noRows = NoOfRows('CustomerTable')-1;

for i=0 to $(noRows)

let a=peek('Customer',$(i),'CustomerTable');
   let b=peek('City',$(i),'CustomerTable');
   let c=peek('Quantity',$(i),'CustomerTable');



GeocodeResponse:
LOAD
status,
'$(a)' as CustomerName,
'$(b)' as CustomerCity,
'$(c)' as CustomerQuantity,
([result/geometry/location/lat]) as latitude,
([result/geometry/location/lng]) as longitude
 FROM [http://maps.google.com/maps/api/geocode/xml?address=$(b)&sensor=false](XmlSimple, Table is [GeocodeResponse]);
  next i;

and the following code for a new tab named Google Map:

// Google Maps Key
gmap_key =“;
max_zoom_level = 14;
Def_zoom_level=7;
Def_map_size=400;

// 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=    '=median(latitude)';
var_mid_long=   '=median(longitude)';
var_zoom=       '=if(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)))<def_map_size 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()))))<def_map_size,_zoom_level,null()),_zoom_level))>def_zoom_level,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)))<def_map_size 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()))))<def_map_size,_zoom_level,null()),_zoom_level)),def_zoom_level)';
var_maptype=    '=if(isnull(only(maptype)),fieldvalue('&chr(39)&'maptype'&chr(39)&',4 ),maptype)';


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 
];

This code was used in previous versions of QlikView and got the results as:

enter image description here

But when I use it for my version. I'm getting the result as:

enter image description here

Do anyone has any idea?

User1493
  • 481
  • 2
  • 7
  • 23
  • 1
    It appears that the only thing not working is the static map image. Your data looks like it could be plotting accurately. Check the map chart's colors tab for the dynamic image expression and ensure that the URL you are building to request the static map from the api is still producing a valid URL. I have `='http://maps.googleapis.com/maps/api/staticmap?center=' & num(var_mid_lat, '##############', '.', ',' ) & ',' & num(var_mid_long, '##############', '.', ',' ) & '&zoom=$(var_zoom)' & '&maptype='&var_maptype & '&size='&map_size_x&'x'&map_size_y & '&sensor=false' ` – bdiamante Dec 06 '16 at 19:23
  • For dynamic image expression I use `='http://maps.google.com/staticmap?center=' &var_mid_lat &',' &var_mid_long&' &zoom=$(var_zoom)'&' &maptype='&var_maptype&’ &size=’&def_map_size’x’&def_map_size&’ &sensor=false’ ` – User1493 Dec 07 '16 at 04:53
  • 4
    As you can see when you visit http://maps.google.com/staticmap, the API has been deprecated. You need to use the latest API instead. – mickeger Dec 07 '16 at 07:42
  • As mick said, update your URL to the new maps.googleapis.com...and that will probably fix it. – bdiamante Dec 07 '16 at 17:12

0 Answers0