def _create_mapping(self, func, switch):
        """Internal function to create the mapping."""
        mapping = {}
        for feature in self.data['features']:
            content = func(feature)
            if switch == 'style':
                for key, value in content.items():
                    if isinstance(value, MacroElement):
                        # Make sure objects are rendered:
                        if value._parent is None:
                            value._parent = self.geojson_obj
                            value.render()
                        # Replace objects with their Javascript var names:
                        content[key] = "{{'" + value.get_name() + "'}}"
            key = self._to_key(content)
            mapping.setdefault(key, []).append(self.get_feature_id(feature))
        self._set_default_key(mapping)
        return mapping
Internal function to create the mapping.