Reputation: 2652
Enjoying getting to know Google Charts and Cloud Datalab. Came across this example that requires an API key and can't determine how to communicate it to the library:
%%sql --module taxi
DEFINE QUERY locations
SELECT FLOAT(pickup_latitude) AS lat, FLOAT(pickup_longitude) AS lon, medallion
FROM [833682135931:nyctaxi.trip_data]
DEFINE QUERY geohashes
SELECT lat, lon,
CONCAT(STRING(FLOOR(lat*1000+0.5)/1000), ':', STRING(FLOOR(lon*1000+0.5)/1000)) AS geoid,
medallion
FROM $locations
WHERE lat != 0 AND lon != 0
DEFINE QUERY hotspots
SELECT FIRST(lat) AS lat, FIRST(lon) AS lon, COUNT(medallion) AS pickups
FROM $geohashes
WHERE ABS(HASH(medallion)) % 1000 == 1
GROUP BY geoid
ORDER BY pickups DESC
LIMIT 25
New cell:
%%chart map --fields lat,lon,pickups --data taxi.hotspots
showTip: true
mapType: normal
key: {my-key-here} # <- just my guess at how to specify the key
Needless to say this didn't work. Originally it threw an error, but now it completes and leaves a blank white space where the chart should be.
How should they be specified in the Google Cloud Datalab cell?
Upvotes: 0
Views: 192
Reputation: 5532
The key needs to be specified in the notebook's Javascript global namespace. Run this in a cell before running your map cell:
%%html
<script src="https://maps.googleapis.com/maps/api/js?key=<YOUR_API_KEY>&callback=initMap" async defer></script>
Upvotes: 3