Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi experts,
I'm trying to use an API Google Map in my qv apps.
I have 3 fields in my file : Customer; Sales; Location
In the field "Location", the GPS data are saved. Example : 49.897399,2.294941
I also have put in the script the API code.
How to do after that to add the map on my sheet ?
Regards,
Pierre.
API sample :
gmap_key = 'ABQIAAAAyYiaEbA9t3e0YKNv7mwqyxSqqe4tBT902slFFxhPpJUJiAYiDRQOAaonJyylIxLYCWKdErJWPkLYRA';
max_zoom_level = 17; //maximum value 18
// 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= '620';
map_size_y= '500';
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
];
I'm not sure what you're question is but you're first problem is that you have both latitude and longitude in the same field. Notice in the variables there is LATITUDE and LONGITUDE. Those names need to be the same as what you're latitude and longititude fields are called. So if you decide to name the latitude field "city_latitude" then you need to replace "latitude" in all of the variables with "city_latitude".
Also I would find an example of a chart w/ Google Maps that already works and just copy/paste it into your .qvw. There are a lot of little things that you'll forget so you're better off doing it that way. You'll need to change all of the expressions to match your latitude and longitude field names along with making sure the dimension matches what you want (city?).
Personally i would add a field for city and have two tables. One with customer, sales, and city and the other with city, latitude, and longitude. Then use city for the dimension in your chart.
Another thing (that I'm not 100% sure about) is that you might need to make sure your longitude is negative (all of my graphs for the United States are, but I don't know what the coordinates are for Europe and how that works). If the points are in weird places, that might be something to consider (but again... I don't know).
Check out the attached. It is working for me.
hth,
Stephen