Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Map issue

Hi, I am using following code for my map and there is a problem with the Georgia because it is displaying the Georgia state in US. How can i change that? please help. Thanks

DISTRICT_LINK_MAP:

LOAD

    Distinct (mid(COUNTRY_NAME,1,(Len(COUNTRY_NAME)-3)))  AS DISTRICT_NAME

FROM

(qvd) Where COUNTRY_NAME<>'SRI LANKA';

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

for i=0 to $(noRows)

//let a = peek('CONTRACT',$(i),'Customer_Master');

    let b = peek('DISTRICT_NAME',$(i),'DISTRICT_LINK_MAP');

   // let c = peek('Quantity',$(i),'CustomerTable');

      

GeocodeResponse:

LOAD

status,

//'$(a)' as CustomerName,

'$(b)' as DISTRICT_NAME,

//'$(c)' as CustomerQuantity,

([result/geometry/location/lat]) as Latitude,

    ([result/geometry/location/lng]) as Longitude

FROM [http://maps.googleapis.com/maps/api/geocode/xml?address=$(b)&sensor=false] (XmlSimple, Table is [GeocodeResponse])

;

next i;

max_zoom_level = 5; //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 = '640';//640

map_size_y = '400';//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

];

set hideprefix = 'maptype';

1 Solution

Accepted Solutions
woshua5550
Creator III
Creator III

like this

DISTRICT_LINK_MAP:

LOAD Distinct

COUNTRY_NAME AS vDISTRICT_NAME,

Mid(COUNTRY_NAME,1,(Len(COUNTRY_NAME)-3))  AS DISTRICT_NAME

FROM

(qvd) Where COUNTRY_NAME<>'SRI LANKA';

//change variable 'b'

Let b = peek('vDISTRICT_NAME',$(i),'DISTRICT_LINK_MAP');

View solution in original post

7 Replies
Not applicable
Author

I want to locate the country "Georgia".

woshua5550
Creator III
Creator III

can you provide this qvd file ?

"COUNTRY_MF.qvd"

Not applicable
Author

Hi Dave, this is the data set in that QVD file. i shared it like this becuase i cant find a place to attach the file. Sorry for the inconvenience. thanks

COUNTRY_CODECOUNTRY_NAME
ABUUnited Arab Emirates;AE
ADEAustralia;AU
AGHTurkmenistan;TM
AJMUnited Arab Emirates;AE
AKTKazakhstan;KZ
ALGAlgeria;DZ
ALMKazakhstan;KZ
ALXEgypt;EG
AMBTurkey;TR
AMSNetherlands;NL
ANKTurkey;TR
ANTBelgium;BE
APANigeria;NG
APISamoa;WS
AQAJordan;JO
ARMArmania;AM
ASTRussian Federation;RU
ATHGreece;GR
ATYKazakhstan;KZ
AUCNew Zealand;NZ
BABIran, Islamic Republic of;IR
BAMMali;ML
BANIran, Islamic Republic of;IR
BATGeorgia;GE
BEDUnited States;US
BEIBenin;BJ
BEJAlgeria;DZ
BELSerbia;RS
BENLibya;LY
BERLebanon;LB
BHABahrain;BH
BIRUnited Kingdom;GB
BISKyrgyzstan;KG
BITIran, Islamic Republic of;IR
BKUAzerbaijan;AZ
BLRRussian Federation;RU
BNKThailand;TH
BSBAustralia;AU
BSPLibya;LY
BSRIraq;IQ
BTQIran, Islamic Republic of;IR
BULBulgaria;BG
BUSSouth Korea;KR
CARAustralia;AU
CELCzech Republic;CZ
CFTUnited States;US
CHAIran, Islamic Republic of;IR
CHLChile;CL
CHNIndia;IN
CHTBangladesh;BD
CICUnited States;US
CLLPeru;PE
CLSChile;CL
COCIndia;IN
CONGuinea;GN
COPDenmark;DK
COTBenin;BJ
CPTSouth Africa;ZA
DAMSaudi Arabia;SA
DETUnited States;US
DKRSenegal;SN
DLCChina;CN
DMASaudi Arabia;SA
DOHQatar;QA
DUBUnited Arab Emirates;AE
DUSTajikistan;TJ
ELKLibya;LY
FAMTurkey;TR
FANChina;CN
FELUnited Kingdom;GB
FLTFrance;FR
FREFreetown;SL
FRKGermany;DE
FRMAustralia;AU
GENItaly;IT
GEVSwitzerland;CH
GNZChina;CN
GOTSweden;SE
GRFAustralia;AU
GYDPoland;PL
HAMGermany;DE
HELFinland;FI
HNGChina;CN
HNLHawaii;HI
HOBAustralia;AU
HONHong Kong;HK
HOUUnited States;US
HPGVietnam;VN
HUAChina;CN
ILIUnited States;US
ILLUkraine;UA
ILLMDMoldova;MD
INCSouth Korea;KR
IQUChile;CL
ISKTurkey;TR
JEBUnited Arab Emirates;AE
JEDSaudi Arabia;SA
JIJChina;CN
KANKanagawa;JP
KARKazakhstan;KZ
KEETaiwan;TW
KHAUkraine;UA
KISIran, Islamic Republic of;IR
KLAMalaysia;MY
KLJLithuania;LT
KLMMalaysia;MY
KOATaiwan;TW
KOSKosovo;AL
KOTRussian Federation;RU
KOWHong Kong;HK
KRCPakistan;PK
KSNMoldova;MD
KUWKuwait;KW
KWIKuwait;KW
KYVUkraine;UA
LAGNigeria;NE
LAPBolivia;BO
LATSyrian Arab Republic;SY
LBHUnited States;US
LEHFrance;FR
LGPUnited Kingdom;GB
LHRUnited Kingdom;GB
LIAChina;CN
LISPortugal;PT
LOBAngola;AO
LOMTogo;TG
LONUnited Kingdom;GB
LOSUnited States;US
LPZGermany;DE
LUAAngola;AO
MACMacau;MO
MALMaldives;MV
MANUnited Kingdom;GB
MELAustralia;AU
MENCzech Republic;CZ
MERTurkey;TR
MIAUnited States;US
MISLibya;LY
MLNItaly;IT
MLTMalta;MT
MLWLiberia;LR
MNLPhilippines;PH
MOGSomalia;SO
MOLMoldova;MD
MOMKenya;KE
MONCanada;CA
MUMIndia;IN
MUNIndia;IN
NAGJapan;JP
NAKAzerbaijan;AZ
NAMAngola;AO
NANChina;CN
NARJapan;JP
NEWUnited States;US
NICCyprus;CY
NRKUnited States;US
NVRRussian Federation;RU
OAKUnited States;US
ODEUkraine;UA
OKIJapan;JP
OSKJapan;JP
OSLNorway;NO
PAPFrench Polynesia;PF
PARFrance;FR
PNGMalaysia;MY
POTGeorgia;GE
POZPoland;PO
PRGCzech Republic;CZ
PRNKosovo;XK
PTHAustralia;AU
PUKUnited Kingdom;UK
PUNChile;CL
QESIran, Islamic Republic of;IR
QNGChina;CN
REYIceland;IS
RIGLatvia;LV
RIYSaudi Arabia;SA
ROTNetherlands;NL
RTBGermany;DE
RUNFrance;FR
SAEEgypt;EG
SAIEgypt;EG
SAMUzbekistan;UZ
SAWEgypt;EG
SHAChina;CN
SHYKazakhstan;KZ
SHZChina;CN
SIHCambodia;KH
SINSingapore;SG
SOUUnited Kingdom;GB
STPRussian Federation;RU
SUVFiji;FJ
SWNSweden;SE
SYDAustralia;AU
TAITaiwan;TW
TARKiribati;KI
TASUzbekistan;UZ
THITaiwan;TW
TILUnited Kingdom;GB
TINNigeria;NG
TLLEstonia;EE
TMAGhana;GH
TNJChina;CN
TOBLibya;LY
TOKJapan;JP
TORCanada;CA
TRBTurkey;TR
TRIItaly;IT
TRPLibya;LY
TSLGreece;GR
TUNTunisia;TN
TUTIndia;IN
ULAMongolia;MN
UMMIraq;IQ
USAUnited States;US
UZBUzbekistan;UZ
VALChile;CL
VANCanada;CA
VICSeychelles;SC
VIEAustria;AT
VLCSpain;ES
VLNSpain;ES
WAPPoland;PL
WAWPoland;PL
YANBurma;MM
YEMYemen;YE
YOKJapan;JP
YRVArmenia;AM
ZHUChina;CN
avkeep01
Partner - Specialist
Partner - Specialist

Hi, maybe you could try the app I created on loading geolocations from Google. Maybe you should edit your URL, just look at my example if you want.

GOOGLE API GEO location loader

woshua5550
Creator III
Creator III

in my opinion

the reason which caused this issue is that there are two "Georgia" in xml data, one is the country Georgia which you want ,another one is the State Georgia in USA which you don't need

you must let b = 'Georgia;GE' rather than 'Georgia' to get the right latotude and longitude

so you can get rid of mid function while loading qvd data like this

DISTRICT_LINK_MAP:

LOAD

    Distinct COUNTRY_NAME AS DISTRICT_NAME

FROM

(qvd) Where COUNTRY_NAME<>'SRI LANKA';

if you really need your original DISTRICT_NAME you can create a new field

Not applicable
Author

Hi Dave, what do you mean by create a new field?

woshua5550
Creator III
Creator III

like this

DISTRICT_LINK_MAP:

LOAD Distinct

COUNTRY_NAME AS vDISTRICT_NAME,

Mid(COUNTRY_NAME,1,(Len(COUNTRY_NAME)-3))  AS DISTRICT_NAME

FROM

(qvd) Where COUNTRY_NAME<>'SRI LANKA';

//change variable 'b'

Let b = peek('vDISTRICT_NAME',$(i),'DISTRICT_LINK_MAP');