How to Build an Affordable and Open-Sourced Mapping Application
Using open-source projects and the event-driven architecture you can make a highly interactive web app with low costs so you can focus on building that great thing.

Intro
Here's a stack of services that can help you deploy a mapping application on the cheap. All of the software components are open-source and are among the top picks leading companies use to build fully featured web apps. A great thing about this stack is you can go serverless with most of these tools. This means you only pay when someone clicks, and you don't have to worry about scaling servers. If you haven't already read more about the serverless stack to get more information about this new design pattern. In this article I'm going to focus on the mapping tools.
Stack
I've grouped the serverless components into a single element to make this diagram easier to read. I'll go into the details of each service below:
Serverless
Much technology has come together to enable serverless architecture, and there are many benefits of using it. In the context of this stack, it makes for faster development and keeps costs low. It's my go-to for developing web apps. An active community has developed around it, and there's a lot of resources available. Plus there's a generous free tier for most if not all of the services among the big three cloud computing companies: AWS, Google Cloud, and Azure.
PostgreSQL
PostgreSQL is an open-source database that has been developed and improved over the last 30 years. It stands toe-to-toe with other relational databases that can cost a fortune to license (e.g. MS SQL Server). It was started at UC Berkley and has enabled businesses and casual users to benefit from a core component of web development without having to fork over a bunch of cash. If you want to let someone else do the server administration check out Amazon RDS for PostgreSQL
PostGIS
PostGIS extends the functionality of PostgreSQL and allows it to store, analyze, and manage spatial data. I've used a leading enterprise GIS database, and having access to something similar at no cost is almost unbelievable. Location queries are run in SQL and below is an example of how to check what superhero is 'contained' by the city 'Gotham.' The core developers and companies that have contributed over the years have created a fantastic piece of software that serves as the backbone for countless learners, builders, and businesses.
SELECT superhero.name
FROM city, superhero
WHERE ST_Contains(city.geom, superhero.geom)
AND city.name = 'Gotham';
Mapbox GL JS
I recently used this in a project for the first time, and it was fairly easy to learn. It's a well developed open source JavaScript library that enabled me to build an interactive web map quickly. This code is released as open-source from the company Mapbox, and it currently has 214 contributors on GitHub. With Mapbox GL JS you can make applications that zoom into an area when something is clicked, add new geometry to data layers, and build stylized web maps. The code below shows how easily you can add a map to your HTML:
mapboxgl.accessToken = '<your access token here>';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/mapbox/streets-v9', // stylesheet location
center: [-74.50, 40], // starting position [lng, lat]
zoom: 9 // starting zoom
});
Turf
A geospatial analysis library is written in JavaScript and maintained by Mapbox. You can do cool things like run buffers, determine if a feature is within another feature, and create triangular irregular networks (typically used for elevation models). Turf is written in JavaScript so you can also use it in Node.js and run it on a server. Combine that with AWS Lambda, and you have a serverless geospatial server! Turf uses geojson as input and here's the lengthy code block to create a buffer:
var point = turf.point([-90.548630, 14.616599]);
var buffered = turf.buffer(point, 500, {units: 'miles'});
OpenStreetMap (OSM)
You have heard of this one, and it's one of the organizations that introduced digital mapping to the world. OSM is a crowd-sourced application of volunteered geographic information that is on par with commercial vendors like Google Maps. It enables large companies and small builders to leverage location in their maps and references an updated model of the world. Think about becoming a contributor, and you can help maintain the worlds largest crowd-sourced dataset.
View Larger Map
A quick word on open-source
I recently participated in a hackathon that required building something that addresses the issue of human trafficking. I set out to create a functioning mapping application very quickly and needed help. Without some of the open-source software we just covered, I wouldn't have been able to develop what I envisioned. These tools helped me by providing a foundation in which to build my application. Instead of spending all my time building geospatial functionality, I was able to focus on the core problem I was trying to solve. I experienced the benefits of open-source software and now fully understand how it can accelerate innovation.
Not only did these tools reduce the time from idea-to-built, but they also helped me psychologically. The open mindset enabled me to break from the old way of thinking and helped me focus on the creative side of things. I wasn't worried about how to protect my code or how to monetize it. I built a better product because of it. Find some cool projects out there and think about contributing to them if you have the skill and time. If you're not there yet, it's possible to make monetary contributions. I plan on contributing one way or another for every open-source tool I use.
Everything together
With this stack, you can make powerful mapping applications that can handle just about anything you throw at it. If you need to run some quick analytics on a data set, you can use Turf on the front end. If you have something that needs to be processed, then PostgreSQL and PostGIS is the way to go. Once the processing is done, you can use Mapbox to map and interact with your data quickly. Mapbox has some amazing stylized base maps that can make your app look great. With all this running on a serverless architecture, you have a highly scalable, highly available application built almost entirely with APIs.