Static Maps¶
StaticMap
¶
Google Static Maps URL builder.
Purpose
Builds static map URLs for markers, paths, and geographic bounding boxes.
Attributes:
| Name | Type | Description |
|---|---|---|
api_key |
Optional[str]
|
Google Maps credential attached to static URLs. |
zoom |
Optional[int]
|
Zoom level for the current static map. |
size |
Optional[str]
|
Map image dimensions in pixels. |
latitude |
Optional[float]
|
Latitude of the current marker. |
longitude |
Optional[float]
|
Longitude of the current marker. |
params |
Optional[Dict]
|
Current Static Maps query parameters. |
markers |
Optional[str]
|
Encoded marker coordinates. |
base_url |
Optional[str]
|
Static Maps HTTP endpoint. |
points |
Optional[list]
|
Coordinates used for markers or path geometry. |
maptype |
Optional[str]
|
Selected static map layer type. |
color |
Optional[str]
|
Marker or path color. |
weight |
Optional[int]
|
Path line weight. |
west |
Optional[float]
|
Western bounding longitude. |
south |
Optional[float]
|
Southern bounding latitude. |
east |
Optional[float]
|
Eastern bounding longitude. |
north |
Optional[float]
|
Northern bounding latitude. |
Initialize Google Static Maps URL configuration and output state.
Purpose
Initialize Google Static Maps URL configuration and output state.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Initializes instance state. |
Source code in mapping.py
Methods:¶
validate_coordinate
¶
Purpose
Validate and normalize a latitude and longitude pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees. |
required |
lng
|
float
|
Longitude in decimal degrees. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple
|
Validated latitude and longitude. |
Source code in mapping.py
normalize_points
¶
Purpose
Normalize coordinate tuples, coordinate lists, or dictionaries with lat/lng fields into validated coordinate tuples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list
|
List of coordinates. Supported item shapes include: (lat, lng), [lat, lng], {'lat': value, 'lng': value}, and {'latitude': value, 'longitude': value}. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
List of validated coordinate tuples. |
Source code in mapping.py
build_url
¶
Purpose
Build a Google Static Maps URL from a parameter dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Dict
|
Google Static Maps query parameters. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Fully-qualified Google Static Maps URL. |
Source code in mapping.py
pin
¶
Purpose
Build a static map URL centered on a coordinate with a single marker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude for the pin. |
required |
lng
|
float
|
Longitude for the pin. |
required |
zoom
|
int
|
Zoom level from 1 through 20. |
12
|
size
|
str
|
Image dimensions in WxH format. |
'400x300'
|
scale
|
int
|
Google Static Maps image resolution multiplier, 1 or 2. |
1
|
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Fully-qualified URL string suitable for embedding. |
Source code in mapping.py
pins
¶
pins(
points: list,
zoom: int = 0,
size: int = "600x400",
maptype: int = "roadmap",
color: int = "red",
) -> str | None
Purpose
Build a static map URL with multiple markers. If zoom is zero, Google is allowed to fit the visible area to the supplied points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list
|
List of coordinate tuples, coordinate lists, or dictionaries containing lat/lng fields. |
required |
zoom
|
int
|
Zoom level. Use zero to omit explicit zoom. |
0
|
size
|
str
|
Image dimensions in WxH format. |
'600x400'
|
maptype
|
str
|
Map type: roadmap, satellite, terrain, or hybrid. |
'roadmap'
|
color
|
str
|
Marker color. |
'red'
|
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Fully-qualified URL string suitable for embedding. |
Source code in mapping.py
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 | |
path
¶
path(
points: list,
size: int = "600x400",
maptype: int = "roadmap",
color: int = "0x0000ff",
weight: int = 5,
) -> str | None
Purpose
Build a static map URL showing a path through two or more points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list
|
List of coordinate tuples, coordinate lists, or dictionaries containing lat/lng fields. |
required |
size
|
str
|
Image dimensions in WxH format. |
'600x400'
|
maptype
|
str
|
Map type: roadmap, satellite, terrain, or hybrid. |
'roadmap'
|
color
|
str
|
Path color. |
'0x0000ff'
|
weight
|
int
|
Path stroke weight. |
5
|
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Fully-qualified URL string suitable for embedding. |
Source code in mapping.py
bbox
¶
bbox(
west: float,
south: float,
east: float,
north: float,
size: int = "600x400",
maptype: int = "roadmap",
) -> str | None
Purpose
Build a static map URL showing a rectangular bounding box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
west
|
float
|
Western longitude. |
required |
south
|
float
|
Southern latitude. |
required |
east
|
float
|
Eastern longitude. |
required |
north
|
float
|
Northern latitude. |
required |
size
|
str
|
Image dimensions in WxH format. |
'600x400'
|
maptype
|
str
|
Map type: roadmap, satellite, terrain, or hybrid. |
'roadmap'
|
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Fully-qualified URL string suitable for embedding. |
Source code in mapping.py
2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 | |