You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: projects/build-a-cafe-finder-with-javascript/build-a-cafe-finder-with-javascript.mdx
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,11 +38,11 @@ tags:
38
38
39
39
**Read Time:** 30 minutes
40
40
41
-
## # Introduction
41
+
## Introduction
42
42
43
43
If you’re an iced-bev-meets-coworking-space fiend like me and want to shake up what cafe you head to next, this is the perfect project for you. We’ll be using our trilogy of web dev tools: ****HTML****, ****CSS****, and ****JavaScript****, and an API from the Google Maps Platform called ****Places****. We’ll also make some quick animations and implement swiping recognition with a JavaScript library called ****Hammer****!
44
44
45
-
## # About the Google Maps Platform
45
+
## About the Google Maps Platform
46
46
47
47
The Google Maps Platform is a collection of Application Programming Interfaces (APIs) and Software Development Kits (SDKs). Each tool on the platform lets users use Google Maps functions and data in their own projects!
48
48
@@ -52,17 +52,17 @@ Some popular apps that use the Google Maps Platform include Uber and Airbnb, whi
52
52
53
53
The [Places API](https://developers.google.com/maps/documentation/places/web-service/overview) is a smaller API under the Google Maps API. It fetches location data like location names, addresses, photos, and many more attributes! It’s a great tool for accessing updated data and finding multiple places without manually copying all of their information into a project. ****We’ll be using this in our project!****
54
54
55
-
## # Setup
55
+
## Setup
56
56
57
-
#### # Workspace
57
+
### Workspace
58
58
59
59
Start by creating a new HTML/CSS/JS project in [Codédex Builds](https://www.codedex.io/builds). You can also use a Code editor of your choice, like [VSCode](https://code.visualstudio.com/).
60
60
61
-
#### # Google Cloud Console
61
+
### Google Cloud Console
62
62
63
63
Set up your project in the [[Google Cloud Console](https://developers.google.com/maps/documentation/elevation/cloud-setup). You’ll enter a project name and billing information. Your website won’t work as it should unless you enable billing, but you won’t be charged if the API doesn’t get called past the monthly limit (we'll teach you how to cap it at the limit, which is usually 10,000 API calls).
64
64
65
-
#### # Clone Template
65
+
### Clone Template
66
66
67
67
Head over to [this GitHub link](https://github.com/gbanaag/codedex-cafe-finder-template/tree/main) and clone the repository. The repo has all the basic HTML and CSS set up so we don’t have to worry about it later and focus on API implementation.
68
68
@@ -74,11 +74,11 @@ You can clone the template in 3 different ways:
74
74
75
75
If you don’t have VS Code and don’t know how to use it, head over to our [VS Code setup tutorial](https://www.codedex.io/projects/set-up-your-local-environment-in-python#download-vs-code).
Head to [https://cors-anywhere.herokuapp.com/](https://cors-anywhere.herokuapp.com/). Make sure to click on the ``Request temporary access to the demo server`` button to get set up with a temporary server for your project.
To see cafes nearby, the browser needs access to your location. There’s a built-in JavaScript function that takes care of that for you called ``useLocation()`` and it takes your device’s latitude and longitude coordinates.
121
121
@@ -152,7 +152,7 @@ We’ll save the location and timestamp in ``localStorage`` in case we use our c
152
152
}
153
153
```
154
154
155
-
#### # Using the API
155
+
### Using the API
156
156
157
157
We’ll start implementing the Google Places API to take locations and their information from Google Maps itself! We’ll start by writing the `useLocation()` function.
158
158
@@ -187,7 +187,7 @@ If the API finds results for nearby cafes, we’ll take that data and insert it
187
187
}
188
188
```
189
189
190
-
## # Cafe UI and Animations
190
+
## Cafe UI and Animations
191
191
192
192
We’re gonna create a wrapper for our cards, and inject data from the API into the wrapper as we go. To start, let’s make a function called ``displayCards()`` that renders a div container whenever the website starts up.
193
193
@@ -255,7 +255,7 @@ wrapper.appendChild(card);
255
255
container.appendChild(wrapper);
256
256
```
257
257
258
-
#### # Hammer
258
+
### Hammer
259
259
260
260
[Hammer](http://hammerjs.github.io/) is a library used to recognize touch gestures in the browser!
261
261
@@ -289,7 +289,7 @@ We’re going to add a function that detects left and right swipes and makes eac
289
289
});
290
290
```
291
291
292
-
#### # Saving Cafes
292
+
### Saving Cafes
293
293
294
294
We’ll be using ``localStorage`` to save cafes to the browser. It automatically caches (saves) specific interactions from your site to your browser that you choose to save without needing a database.
295
295
@@ -370,7 +370,7 @@ container.appendChild(card);
370
370
}
371
371
```
372
372
373
-
## # Conclusion
373
+
## Conclusion
374
374
375
375
Here's my final result:
376
376
@@ -384,12 +384,12 @@ If you’re looking for another challenge or a way to spice up your project, you
384
384
- Adding a map of places next to the cards
385
385
- Animating your cards further
386
386
387
-
#### # Troubleshooting
387
+
### Troubleshooting
388
388
389
389
- Make sure you’re granted temporary access on https://cors-anywhere.herokuapp.com/.
390
390
- Make sure to allow location access when you try out the site.
391
391
392
-
## ### Additional Resources
392
+
### Additional Resources
393
393
394
394
- [GitHub repository with all the code](https://github.com/gbanaag/codedex-cafe-curator)
0 commit comments