I’ve tried with both address, location name and coordinates.
How can I get the map to work inside the card?
This is how I create coordinates:
def get_coordinates(order_info):
try:
adress - order_info.get('DeliveryAddress1') + ", " + order_info.get(
'DeliveryZipCode') + ", " + order_info.get('DeliveryCity')
gmaps = googlemaps.Client(key=google_maps)
geocode_result = gmaps.geocode(address)
location = geocode_result[0]['geometry']['location']
coordinates = f"{location['lat']},{location['lng']}"
return coordinates
except Exception as e:
print(f"An error occurred: {e}")
and this is how I send it over:
def do_create_card(name, desc, due, order_info):
start_date = get_comment_if_exist_but_only_for_start_date(order_info)
coordinates = get_coordinates(order_info)
url = "https://api.trello.com/1/cards"
querystring = {"name": name, 'desc': desc, 'coordinates': coordinates, "idList": config.trello_list("new"),
"keepFromSource": "all", "key": key, "token": token}
if due == start_date:
querystring['due'] = due
querystring['start'] = str(start_date)
if due != start_date:
querystring['due'] = str(start_date)
querystring['start'] = due
try:
r = requests.request("POST", url, params=querystring)
if r.ok:
return r.json()
else:
print("failed to create trello card", r.status_code, querystring, desc)
return
except:
error = sys.exc_info()
print(f"An error occurred: {error}")
return