DEV Community

Cover image for Create Map Images Using the Static Map Function of Amazon Location Service v2
Yasunori Kirimoto for AWS Heroes

Posted on

Create Map Images Using the Static Map Function of Amazon Location Service v2

In November 2024, Amazon Location Service v2 was finally released!

You can find out more in this article, so please check it out.

This article will introduce how to use the static map (GetStaticMap) in the Maps API. This function was newly added with Amazon Location Service v2, and you can create map images with the specified parameters.

The thread I posted on X also summarizes the recommended points of v2. 🗺️

https://x.com/dayjournal_nori/status/1855029985108795676

Advance Preparation

Create an API key for Amazon Location Service v2

Amazon Location Service #007 - API Key Creation (v2)

How to use the static map

Using the static map function of Amazon Location Service v2, you can easily create map images that can be used for various purposes, such as storing maps and reports, simply by specifying parameters in the URL. As of November 2024, the available map styles are limited to "Satellite," but there is also the possibility that new styles will be added. Here, we will introduce some examples of basic parameters, but many more are available. Please try customizing them.

Creating a basic map image

As a basic example, we will create a map of the area around Tokyo Station with a zoom level of 14, an image size of 1024px, and a scale bar included.

https://maps.geo.ap-northeast-1.amazonaws.com/v2/static/map?&style=Satellite&scale-unit=Kilometers&center=139.767,35.681&width=1024&height=1024&zoom=14&key=v1.public.xxxxx
Enter fullscreen mode Exit fullscreen mode

Endpoint: https://maps.geo.${region}.amazonaws.com/v2/static/
FileName: map
Style: style=Satellite
ScaleBarUnit: scale-unit=Kilometers
Center: center=139.767,35.681
Width: width=1024
Height: height=1024
Zoom: zoom=14
API key: key=v1.public.xxxxx

img

Create a zoomed in map image

Next, let's create a map image with the zoom level increased from 14 to 16, using the basic example.

https://maps.geo.ap-northeast-1.amazonaws.com/v2/static/map?&style=Satellite&scale-unit=Kilometers&center=139.767,35.681&width=1024&height=1024&zoom=16&key=v1.public.xxxxx
Enter fullscreen mode Exit fullscreen mode

Zoom: zoom=16

img

Create a map image with added point information

Finally, create a map image with added point information as an overlay. If it is a simple object, you can add it by specifying the parameters.

https://maps.geo.ap-northeast-1.amazonaws.com/v2/static/map?&style=Satellite&scale-unit=Kilometers&center=139.767,35.681&width=1024&height=1024&zoom=16&compact-overlay=point:139.767,35.681;label=Tokyo Station;size=large&key=v1.public.xxxxx
Enter fullscreen mode Exit fullscreen mode

CompactOverlay: compact-overlay=
Point: point:139.767,35.681;
Label: label=Tokyo Station;
Size: size=large

img

Related Articles

References
Amazon Location Service

Top comments (0)