How to add boundaries to Google Maps
23rd November 2021
Initializing a map
Don't forget you'll need to replace the access token in the example with your own.
loadGeoJSON method on that object to load a GeoJSON file which will then add the coordinates in that file onto the map.
In the example below we have loaded a GeoJSON file containing the boundary for Leeds UK and then used a bit of styling to improve it's appearance.
Although this is a basic example, that's pretty much all there is to it. The find out about more advanced styling and to hook into events check out Google's documentation page on the Data Layer.
Obtaining GeoJSON data
If you want to play around further with boundaries, you can purchase the Ultimate UK Map Boundary dataset which contains 11,737 boundaries for £49.99. The download contains seperate GeoJSON files for each city / town / parish boundary so you can easily integrate it into your application.
It's also a life time license which allow you to use the dataset on any number of personal and commercial projects.