MCPcopy Index your code
hub / github.com/python-visualization/folium / _create_mapping

Method _create_mapping

folium/features.py:901–919  ·  view source on GitHub ↗

Internal function to create the mapping.

(self, func: Callable, switch: str)

Source from the content-addressed store, hash-verified

899 return self._create_mapping(highlight_function, "highlight")
900
901 def _create_mapping(self, func: Callable, switch: str) -> TypeStyleMapping:
902 """Internal function to create the mapping."""
903 mapping: TypeStyleMapping = {}
904 for feature in self.data["features"]:
905 content = func(feature)
906 if switch == "style":
907 for key, value in content.items():
908 if isinstance(value, MacroElement):
909 # Make sure objects are rendered:
910 if value._parent is None:
911 value._parent = self.geojson_obj
912 value.render()
913 # Replace objects with their Javascript var names:
914 content[key] = "{{'" + value.get_name() + "'}}"
915 key = self._to_key(content)
916 feature_id = self.get_feature_id(feature)
917 mapping.setdefault(key, []).append(feature_id) # type: ignore
918 self._set_default_key(mapping)
919 return mapping
920
921 def get_feature_id(self, feature: dict) -> Union[str, int]:
922 """Return a value identifying the feature."""

Callers 2

get_style_mapMethod · 0.95
get_highlight_mapMethod · 0.95

Calls 4

_to_keyMethod · 0.95
get_feature_idMethod · 0.95
_set_default_keyMethod · 0.95
renderMethod · 0.45

Tested by

no test coverage detected