mypy-boto3-geo-maps

1.42.84 · active · verified Sat Apr 11

mypy-boto3-geo-maps provides type annotations for the `boto3` AWS LocationServiceMapsV2 service. It enhances development with static type checking, autocompletion, and improved code readability for `boto3` users. The library is actively maintained with frequent updates, aligning with `boto3` releases and the `mypy-boto3-builder`'s development cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted `LocationServiceMapsV2Client` and construct a typed request using `TypeDef`s provided by `mypy-boto3-geo-maps`. The `TYPE_CHECKING` block ensures that these imports are only used by type checkers, avoiding runtime dependencies. Replace placeholder values and ensure AWS credentials are configured for actual execution.

import boto3
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_geo_maps.client import LocationServiceMapsV2Client
    from mypy_boto3_geo_maps.type_defs import CreateMapRequestRequestTypeDef

# Get a typed client for AWS Location Service (Maps V2)
client: 'LocationServiceMapsV2Client' = boto3.client("geo-maps")

# Example usage with a typed request (for illustration, not runnable without AWS creds)
try:
    # Define a request payload using TypeDef
    create_map_request: CreateMapRequestRequestTypeDef = {
        "MapName": "MyTestMap",
        "Configuration": {"Style": "VectorEsriStreets"},
        "Description": "A test map created via mypy-boto3-geo-maps",
    }

    # The actual API call (will raise ClientError without valid AWS setup)
    response = client.create_map(**create_map_request)
    print(f"Successfully initiated map creation: {response['MapArn']}")

except client.exceptions.ConflictException as e:
    print(f"Map already exists: {e}")
except Exception as e:
    print(f"An error occurred: {e}")

# Example of getting a static map (assuming a map exists and permissions are set)
# This call would require valid map name and API key if used publicly
# response = client.get_static_map(
#     MapName="MyTestMap",
#     CenterX=-77.0369,
#     CenterY=38.9072,
#     Zoom=12,
#     Width=400,
#     Height=300
# )
# print(f"Received static map data: {len(response['ImageData'])} bytes")

view raw JSON →