What's my altitude?

I made a thing today

I’ve been wanting to put something like this together for myself for a while and I finally found myself with a couple of hours to spare today. The main reason is that I have to calibrate my GPS watch with my current altitude to be able to get accurate elevation readings using the watch’s barometer. So to be able to quickly get my current elevation based on map data for my location I thought this would be quite handy (at least whenever I’ve mobile reception).

It’s a little overkill but it’s built in React. There are even a couple of token tests in there - mainly for the sake of using Jest snapshots which I’ve not used up until this point.

It’s a simple little app that takes your location from navigator.geolocation.getcurrentposition, fires it off to the google elevation service (for now at least) which returns your elevation in metres.

It was a bit of a ball-ache setting up the Google API, there’s a lot of configuration to be done in their control panel to make sure you can get requests through and initially I just tried hitting their elevation API directly not realising this was blocked by CORS so I had to use their Google maps Javascript API.

I’m going to look for an alternative API to google’s for getting the elevation as they are charging £0.005 per request. It’s fine for now - when I signed up to their cloud platform I was given ~£220 ($300) free credit. I should be good for about 44000 requests which I’d be surprised to ever come close to.

I had a quick look and came across open elevation but their open API was very slow to the point of unusable. I may look at firing up a Digital Ocean droplet to host my own instance but that’s for a later date (if at all). If anyone has any other suggestions, please do let me know.

It’s all hosted on an S3 bucket. I’m still trying to get my head around AWS so it was a nice little project to have a play with that too.

You can take a look at WHAT’S MY ALTITUDE? and see the code on my Github (if you want to try this out make sure you set up your .env file as per the .README).

Happy to answer any questions/comments.

Cheers