Google maps API v3 doesnt get the coordinates - google-maps-api-3

this is my code in Qlickview:
let noRows = NoOfRows('GoogleMaps')-1;
for i=0 to $(noRows)
let a=peek('CUSTACCOUNT',$(i),'GoogleMaps');
let b=peek('Adresa',$(i),'GoogleMaps');
Data:
LOAD
'$(a)' as [Kupac šifra],
'$(b)' as Adresa,
subfield([Response/Placemark/Point/coordinates], ',' ,1) AS longitude,
subfield([Response/Placemark/Point/coordinates], ',' ,2) AS latitude
FROM [http://maps.googleapis.com/maps/geo?q=$(b)&output=xml&oe=utf8&key=AIzaSyBByoqS6QmwjSOSRDIOxRe82cUW-iLYJo4] (XmlSimple, Table is [kml]);
next i;
The "output" looks like this:
Data:
LOAD
'454874' as [Kupac šifra],
'Frankfurt Deutschland' as Adresa,
subfield([Response/Placemark/Point/coordinates], ',' ,1) AS longitude,
subfield([Response/Placemark/Point/coordinates], ',' ,2) AS latitude
FROM [http://maps.googleapis.com/maps/geo?q=Frankfurt Deutschland&output=xml&oe=utf8&key=AIzaSyBByoqS6QmwjSOSRDIOxRe82cUW-iLYJo4] (XmlSimple, Table is [kml])
The communication with google doesnt work, there are no coordinates beeing returned. Can somebody pls help me?

I'm facing the same issue and found following:
https://developers.google.com/maps/documentation/geocoding/?hl=de
Since 8.3.2013 the geocoding API 2.0 is no more supported.
New coding is:
http://maps.googleapis.com/maps/api/geocode/output?parameters

next update:
please refer to this link:
http://community.qlikview.com/thread/46602
This coding gets state from google as well and in my case I get 610 = bad key
http://community.qlikview.com/servlet/JiveServlet/download/188551-30764/QVGeocodeur.qvw

last update:
if you modify your url with this string, you will see the status:
[http://maps.googleapis.com/maps/api/geocode/xml?address=$(vAddress)+fr&output=csv&oe=utf8&sensor=false&key=AIzaSyBByoqS6QmwjSOSRDIOxRe82cUW-iLYJo4]
Mine is still REQUEST_DENIED. I guess it's maybe our domain is at google's price list and they avait we do register as "google maps api for companies".

Solution is:
Table:
ADD LOAD
'$(i)' as Rowno ,
#1,
#2,
#3 as latitude,
#4 as longitude
FROM
[http://maps.googleapis.com/maps/api/geocode/json?address=$(vAddress)&sensor=false]
BE AVARE, that your postal Data are concatenated with
,+
like in the example:
http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false

do this trick, it's definitelly working:
http://www.qvsource.com/wiki/General-Web-Connector-For-QlikView.ashx#Example_2
1) open QV Script
2) open wizard Web File
3) copy&paste this link http://maps.google.com/maps/api/geocode/XMLaddress=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false
4) choose XML
5) three tables will be generated, just to simplify the queries use only GeoCodeResponse:
6) Data in address do not have to include any special letters (Ö => Oe, ...) and should be concatenated with ,+ signs

Try this:
Data:
LOAD
'454874' as [Kupac šifra],
'Frankfurt Deutschland' as Adresa,
subfield([lng], ',' ,1) AS longitude,
subfield([lat], ',' ,1) AS latitude
FROM [http://maps.googleapis.com/maps/api/geocode/xml?address=Frankfurt Deutschland&sensor=false] (XmlSimple, Table is [GeocodeResponse/result/geometry/location]);

Related

Every possible combination of lists in google earth engine

I want to get possible combinations of two sets of lists in google earth engine, but my code did not works.
var Per1= ee.Array([[0.1,0.5,0.8],[0.4,0.5,0.2]])
var pre = PercFin1.toList()
var CC=ee.List([1,2,3]);
var ZZ = pre.map(function(hh){
var Per11 = ee.List(pre).get(hh);
var out = CC.zip(Per11);
return out;
});
print (ZZ)
The error I get is:
List.get, argument 'index': Invalid type. Expected: Integer. Actual: List.
Thanks in advance
I don't know if this is what you want, but it looks like you've got the right idea but made an incidental mistake: hh is not an index into pre but an element of it.
I modified and simplified the last part of your code (along with changing PercFin1 to Per1, which I assume was a typo):
var ZZ = pre.map(function(hh){
return CC.zip(hh);
});
print(ZZ);
The result of this is
[
[[1,0.1],[2,0.5],[3,0.8]],
[[1,0.4],[2,0.5],[3,0.2]]
]
which is what I understand you want — each row in Per1 individually zipped with CC.

Query is unable to match parts after "/" or parts within "()" in the data

I have a search request written as
import sqlite3
conn = sqlite3.connect('locker_data.db')
c = conn.cursor()
def search1(teacher):
test = 'SELECT Name FROM locker_data WHERE Name or Email LIKE "%{0}%"'.format(teacher)
data1 = c.execute(test)
return data1
def display1(data1):
Display1 = []
for Name in data1:
temp1 = str(Name[0])
Display1.append("Name: {0}".format(temp1))
return Display1
def locker_searcher(teacher):
data = display1(search1(teacher))
return data
This allows me to search for the row containing "Mr FishyPower (Mr Swag)" or "Mr FishyPower / Mr Swag" with a search input of "FishyPower". However, when I try searching with an input of "Swag", I am then unable to find the same row.
In the search below, it should have given me the same search results.
The database is just a simple 1x1 sqlite3 database containing 'FishyPower / Mr Swag'
Search Error on 'Swag'
Edit: I technically did solve it by limiting the columns being searched to only 'Name' but I intended the code search both the 'Name' and 'Email' columns and output the results as long as the search in within either or both columns.
Edit2: SELECT Name FROM locker_data WHERE Email LIKE "%{0}%" or Name LIKE "%{0}%" was the right way to go.
I'm gonna guess that Mr. FishyPower's email address is something like mrFishyPower#something.com. The query is only comparing Email to teacher. If it was
WHERE Name LIKE "%{0}%"
OR Email LIKE "%{0}%"'
you would (probably) get the result you want.

dbgrid looping to update data not working

so I have a DBGRID that has this infos :
I wanted to edit values inside that DBGRID. I provide a button with codes :
var ptlok, idp, tgl, after, kode, jlh, sql, sqla:string;
begin
while not dbgrid2.DataSource.DataSet.Eof do
begin
ptlok:=dbgrid2.DataSource.DataSet.Fields[0].AsString;
tgl:=dbgrid2.DataSource.DataSet.Fields[1].AsString;
after := stringreplace(tgl, '/', '-', [rfReplaceAll, rfIgnoreCase]);
kode:=dbgrid2.DataSource.DataSet.Fields[2].AsString;
jlh:=dbgrid2.DataSource.DataSet.Fields[3].AsString;
idp:=dbgrid2.DataSource.DataSet.Fields[4].AsString;
sql:='update kasir_opname_detail set kode='+quotedstr(kode)+',
jumlah='+quotedstr(jlh)+' where ptlokasi='+quotedstr(ptlok)+' and
tanggal=to_date('+quotedstr(after)+','+quotedstr('dd-mm-yyyy')+')'+' and
idpay='+quotedstr(idp)+'';
sqla:=sql;
zquery13.close;
zquery13.sql.clear;
zquery13.sql.add(sqla);
zquery13.execsql;
dbgrid2.DataSource.dataset.Next;
showmessage(sqla);
//end;
label19.Caption:=sqla;
end;
showmessage('Data Berhasil Disimpan!');
end;
However the data aren't saved as expected. it will only read last line of DBGRID then updates all data with values from last line of DBGRID.
is there something wrong with the code?
(prev it works with different dbgrid)
I am using delphi 7 and oracle as database. Thanks in advance.

Arugment Error in Google Sheets Custom Function

I created a custom script in Google Sheets using Retrieving location address based on place name and city in Google Spreadsheet. Its is awesome! I wanted to modify the syntax to use the lat long instead of the city and state. I came up with the following:
function mapAddress(SiteName,LatLong) {
var Radius = '100';
var API_KEY = 'XXXXXX';
var url = 'https://maps.googleapis.com/maps/api/place/textsearch/json?query=' +
SiteName + '&location=' + LatLong + '&radius=' + Radius + '&key=' + API_KEY;
var response = UrlFetchApp.fetch(url);
var json = response.getContentText();
obj = JSON.parse(json);
addr = obj.results[0].formatted_address;
return addr;
}
Unfortunately I get an invalid argument in line 6 even though it creates a url that I can post in a browser and get valid results.
Invalid argument:
https://maps.googleapis.com/maps/api/place/textsearch/json?query=BurgerKIng&location= 35.221997,-101.831297&radius=100&key=XXXXXX
(line 6).
I have tried encoding the url but nothing helps. I am a newbie coder but this is about to drive me nuts. Would you be kind enough to help?
For posterity and to close the question: you noted in a comment that there was a space in the source data, resulting in a space after the = in the URL. Removing this resolved the issue.
The answer was "could it be theres a space in location= 35.." as I mentioned in my comment. You can accept this as the answer for others to see.

If Else in R, if product ID is X then change Product Name

I am trying to figure out what is working and why the other way is not working for me.
At the moment I have a list of shops I use and I need to change the naming every time; so I have decided to go by the product_id which never changes, but my code is not working.
product_id <- vector()
This one is not working:
product_name[product_id == '40600000003'] <- 'my cool store']
but this one does work:
product_name[product_name == 'my#cool#Store'] <- 'my cool store'
Now, I am not sure what am I doing wrong, I tried to do:
if (product_id == '40600000003') {
product_name = 'my cool shop'
}
I have a list of 15 shops that I need to change the naming as they arrive in the wrong format from the api connection.
Try 40600000003 instead of '40600000003' it's more than likely reading your vector slots as int if it doesn't contain any characters

Resources