Git Product home page Git Product logo

cloud-tasks-pizza-map's Introduction

Cloud Tasks Pizza Map

Google Maps of Earth with 16k pins

As featured on Medium: https://medium.com/p/db888675db71/

A sample application using Cloud Tasks and Google Maps to find the best pizza restaurants around the world.

The program works in the following way:

  1. Creates a Cloud Tasks Queue
  2. Creates ~10,000 Cloud Tasks with different names of cities
  3. Each Cloud Task triggers a Cloud Function. This Function does the following:
    1. Looks up the best pizza restaurant in that city accoring to the Google Maps Places API
    2. Stores the restaurant data in Firestore

An application architecture diagram of the Cloud Tasks with an HTTP target of a Cloud Function. The Cloud Function uses the Google Maps Nearby/Places APIs for map data and Firestore to store location data.

Setup

This sample uses many APIs and a Firestore database that must be enable prior to running the application.

Enable all APIs

The following APIs are used in this app:

  • Cloud Tasks API
  • Maps Places API
  • Maps Geocoding API
  • Firestore API

Enable these APIs.

Create a Firestore database

Create a Firestore database with these configurations:

  • Mode: Test mode
  • Collection: tasks-pizza.

Create an API Key

Create a Google Maps API key. Create an .env file with a Google Maps API key:

KEY=AIeSyDh7ggKmvLzFAeq_ICGkO8ryvEMm3Nrde-z

Run the Functions Framework

The Functions Framework enables you to run a Google Cloud Function locally on your computer. This is very useful for testing our code.

To test our server locally, follow these instructions using our KEY from the previous step:

npm i
KEY=??? npm start

Observe the Functions Framework starts a server and logs information:

npx: installed 52 in 8.771s
Serving function...
Function: function
URL: http://localhost:8080/

Go to URL specified to view all routes for the application.

Deploy to Google Cloud

You have two options for deploying this application to Google Cloud:

  • Cloud Functions
  • Cloud Run

The gcloud commands for deploying to each target are in the scripts.sh file.

Deploy to Google Cloud Function

Deploy your function on Google Cloud Functions on runtime Node 10:

npm run functions

Deploy to Google Cloud Run

You can also deploy this application to Cloud Run by first building the container, then deploying:

npm run cloudrun

GIF

Here is a GIF of the applicaiton working at different Google Map zoom levels A Google Map with thousands of pins at different zoom levels

cloud-tasks-pizza-map's People

Contributors

grant avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.