MCPcopy
hub / github.com/python-visualization/folium / GeoJsonTooltip

Class GeoJsonTooltip

folium/features.py:1265–1341  ·  view source on GitHub ↗

Create a tooltip that uses data from either geojson or topojson. Parameters ---------- fields: list or tuple. Labels of GeoJson/TopoJson 'properties' or GeoPandas GeoDataFrame columns you'd like to display. aliases: list/tuple of strings, same length/order as fi

Source from the content-addressed store, hash-verified

1263
1264
1265class GeoJsonTooltip(GeoJsonDetail):
1266 """
1267 Create a tooltip that uses data from either geojson or topojson.
1268
1269 Parameters
1270 ----------
1271 fields: list or tuple.
1272 Labels of GeoJson/TopoJson 'properties' or GeoPandas GeoDataFrame
1273 columns you'd like to display.
1274 aliases: list/tuple of strings, same length/order as fields, default None.
1275 Optional aliases you'd like to display in the tooltip as field name
1276 instead of the keys of `fields`.
1277 labels: bool, default True.
1278 Set to False to disable displaying the field names or aliases.
1279 localize: bool, default False.
1280 This will use JavaScript's .toLocaleString() to format 'clean' values
1281 as strings for the user's location; i.e. 1,000,000.00 comma separators,
1282 float truncation, etc.
1283 Available for most of JavaScript's primitive types (any data you'll
1284 serve into the template).
1285 style: str, default None.
1286 HTML inline style properties like font and colors. Will be applied to
1287 a div with the text in it.
1288 sticky: bool, default True
1289 Whether the tooltip should follow the mouse.
1290 **kwargs: Assorted.
1291 These values will map directly to the Leaflet Options. More info
1292 available here: https://leafletjs.com/reference.html#tooltip
1293
1294 Examples
1295 --------
1296 # Provide fields and aliases, with Style.
1297 >>> GeoJsonTooltip(
1298 ... fields=["CNTY_NM", "census-pop-2015", "census-md-income-2015"],
1299 ... aliases=["County", "2015 Census Population", "2015 Median Income"],
1300 ... localize=True,
1301 ... style=(
1302 ... "background-color: grey; color: white; font-family:"
1303 ... "courier new; font-size: 24px; padding: 10px;"
1304 ... ),
1305 ... )
1306 # Provide fields, with labels off and fixed tooltip positions.
1307 >>> GeoJsonTooltip(fields=("CNTY_NM",), labels=False, sticky=False)
1308 """
1309
1310 _template = Template(
1311 """
1312 {% macro script(this, kwargs) %}
1313 {{ this._parent.get_name() }}.bindTooltip("""
1314 + GeoJsonDetail.base_template
1315 + """,{{ this.tooltip_options | tojavascript }});
1316 {% endmacro %}
1317 """
1318 )
1319
1320 def __init__(
1321 self,
1322 fields: Sequence[str],

Callers

nothing calls this directly

Calls 1

TemplateClass · 0.90

Tested by

no test coverage detected