Capture Maps Backend API
This API captures detailed images of an area
using Google Maps Static API
This API is intended to be consumed by Capture Maps UI. However, it is may be consumed by other systems as is.
Setup
-
Create configs/config.toml
in the project root and store Google Maps Static API
cd configs/; cp config.toml.template config.toml
-
Run project
go run src/main.go
Docker Dev
Set GOOGLE_MAPS_API_KEY
in deploy/docker-compose.yml
cd deploy
docker compose up --build -d
Docker Dev
Set GOOGLE_MAPS_API_KEY
in deploy/docker-compose.prod.yml
cd deploy
docker compose -f docker-compose.prod.yml up -d
Sample request
POST /print
Content-Type: application/json
{
"lat": 30.316963,
"lng": 78.032560,
"zoom": 15,
"radius": 5
}
Sample Response

Access-Control-Allow-Origin: *
Content-Type: image/png
Transfer-Encoding: chunked
What about the watermark?
According to Google Maps Platform Terms of Service,
the branding, logos, and copyright and trademark notices can not be removed. :'(
How does it work?
- Latitude and longitudes are converted to Google maps tile coordinates (the first tile is the
centre)
- The specification (the level of details and area it covers) is defined by the combination
of
zoom
, scale
, and pixels
(scale
and pixels
are internally configured)
- The tiles coordinate around the center tile is calculated using the
radius
. The radius
is
number of tiles from the center tile (inclusive)
- The tiles are then joined together and to construct a single detailed image
- Then do the same north and south to the center row
For example, the centre row of the complete grid consists individual tiles collected from west to
east with length 2 * radius - 1
c1 |
c2 |
c3 |
c4 |
c5 |
c6 |
c7 |
c8 |
c9 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
After stitching the tiles we get the centre row
