Pass parameter to 'map_layer_name: '

  • 5 March 2021
  • 3 replies

I want to allow for a map to be built either for world countries or US States.  I have created a parameter picker for US/World but can’t figure out how to pass this parameter to the ‘map_layer_name: ‘.  Is this possible?

This topic has been closed for comments

3 replies

Userlevel 7
Badge +1

How is your data modelled in LookML? map_layer_name is attached to a field, are you saying that your dimension has either country or US state as a value?


Anyway, map_layer_name does not accept Liquid statements, hence there’s no way to parameterise it

I have a field that is US State (or international state if not in US) and a field that is Country.  Both have the appropriate map_layer_name associated.  I was hoping to build a dynamic field that would accept user input for either US State or country and construct a map accordingly.  The problem is the dynamic field doesn’t inherit the map_layer_name from the source field and I’m finding no way for the new field to support both types of maps.  Thanks for your response Dawid - I think you are correct that there is no way for a map_layer_name to accept a parameter.

Userlevel 7
Badge +1

Perhaps if you had a lot of geographical fields, it would be all right to have a parameter. I have been working with maps a lot recently and I have just realised that I would have a use case for what you proposing. Mostly a administrative level inside a country. For example I have a country filter, let’s say, United Kingdom, and then I have few fields that are universal for all countries. 

Region, county, district, parish would be for UK but in a database I would probably model it in level_1, level_2, level_3, level_4. Because the names differ between the countries but it’s all about the level.

In this case I would like to combine level + country to dynamically assign a map to the level field. The combination of liquid and inheritance of map_layer_name would work wonders.