Best way to use map layers in a project

LucianaPadua
Participant II

Hi, 

At Holidu, we have our own definition of vacation areas in our Postgres database, using polygons, and they are updated quite frequently. 

So far I have managed to generate the .toposjon file, upload it to our files folders and use it for one model. But this approach is quite manual, and I would like to find a better way to do the following:

  • use the map_layer from a URL in our drive or git repository that’s not public
    • according to help documents, the map layer can be a file or a URL. Given that our areas change frequently, I would like to have the URL option as I will automate this. But when I tried to use a URL from internet as in the example here, it didn’t work. Do I need to change anything in the settings for Looker to access external URLs?
  • use the same map_layer in each model
    • we have several models where this map_layer could be applied and instead of needing to add it in each model, I would like it to be available for the whole project. We are not using manifest files yet in our instance. Would this be an option? If so how? 

@Dawid I have seen you are quite active on this topic, so I hope it’s ok for me to tag you here. 

Thanks! 

0 13 1,155
13 REPLIES 13

Dawid
Participant V

Hi @LucianaPadua 

Totally okay to tag me 🙂

For the second one, what I did was the following:

  1. Create a model called “map_layers”
  2. Include this model in other models
5c5fca4c-6b52-4e1c-8eec-37813cac5609.png
1b3694e0-a40e-4e78-bf4a-1ffc1b92da87.png

This way you’re only defining map layers once

Dawid
Participant V

As for the first point, I tried to put one of my maps into Google Drive and made it public but in the console we’re getting an error:

Access to fetch at 'https://drive.google.com/file/d/<slug>/view?usp=sharing' from origin 'https://<name>.eu.looker.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Then, I tried with a public gist: https://gist.github.com/moseleyi/c0f17fb580b5adbb73d2787d51f5b446 and I also got the same error, which means along the way the functionality must have been not looked at when changing CORS policy.

I created a ticket in Pendo for that: https://portal.feedback.us.pendo.io/app/#/case/169447?currentProductId=53ee6715-9dcb-471f-bd41-7846a...

LucianaPadua
Participant II

Thanks a lot @Dawid very useful the trick about creating one model specific. I wish we could do this from manifest somehow, but I have not informed myself quite well on Manifest. 

Dawid
Participant V

Actually, I think the models make sense-ish. With models you can further split the map layers if necessary. You could have one huge model and then other models specific to continents, countries, or custom-made. For logical modelling it wouldn’t matter.

For physical modelling, it would give you a lot more clarity in the structure of folders and files and make it easier to find things.

Manifest is just a file that contains things that do not fit anywhere else and are not strictly coding blocks, like map_layer is.

LucianaPadua
Participant II

great, I will implement your recommendation! 

Hello community.

Taking advantage of the post made by Luciana Padua, I would like to share a question with you. I'm starting my walk in the looker so I don't have much knowledge yet.

I'm making a dashboard using a map layer in the Developer module. I managed to get it to work. But when I go to validate the data to commit, Looker is returning the following error message:

No map layer named "regions" is defined. Must be one of "countries", "uk_postcode_areas", "us_counties_fips", "us_states", "us_zipcode_tabulation_areas"
foto_cle.view:253 FOTO_CLE_DASHBOARD:foto_cle

Sorry for the spelling errors. I don't speak English well and I'm using Google translate to write this message.

Thank you all for the attention.

Dawid
Participant V

Hi @neubert_borges !

It’s perfectly okay to start new thread even if your question touches on the smiliar topic 🙂

As for your question, can you show us the code of the dimension from the line that throws errors. As you can see “regions” is not a correct map_layer_name to use in a dimension. There’s no such map built-in in Looker, unless you created it yourself.

The only available options out of the box are:

  • countries
  • uk_postcode_areas
  • us_states
  • us_zipcode_tabulation_areas 
  • us_counties_fips 

Which means your dimension must have one of these values in map_layer_name parameter or your custom map must be defined in a model of your view

Hi @neubert_borges !

It’s perfectly okay to start new thread even if your question touches on the smiliar topic 🙂

As for your question, can you show us the code of the dimension from the line that throws errors. As you can see “regions” is not a correct map_layer_name to use in a dimension. There’s no such map built-in in Looker, unless you created it yourself.

The only available options out of the box are:

  • countries
  • uk_postcode_areas
  • us_states
  • us_zipcode_tabulation_areas 
  • us_counties_fips 

Which means your dimension must have one of these values in map_layer_name parameter or your custom map must be defined in a model of your view

Hi David, thank you very much for answering me.

In fact the map used does not exist in Looker. I created a map layer using a topojson file containing the states of Brazil.

I'll put the dimension code just below:

  dimension: uf_main_account {
     type: string
     map_layer_name: regions
     sql: ${TABLE}.UF_CONTA_PRINCIPAL ;;

Thank you very much for the help.

Dawid
Participant V

Okay, if you created the map, you need to make sure it’s defined in the model where your explore is defined as well

Okay, if you created the map, you need to make sure it’s defined in the model where your explore is defined as well

I think I understand David.
I believe he is. I'll put the code here so you can have a look:

# Define the database connection to be used for this model.
connection: "test_looker"

# include all the views
include: "/views/**/*.view"

# Datagroups defines the caching policy for an Explore. to learn more,
# use the Quick Help panel on the right to see documentation.

datagroup: POC_EMBRATEL_FINAL_default_datagroup {
   # sql_trigger: SELECT MAX(id) FROM etl_log;;
   max_cache_age: "1 hour"
}

map_layer: regions {
   file: "/models/Maps/br_states.json"
   format: topojson
   label: "Regions"
   property_key: ""

Dawid
Participant V

Hi,

It’s Dawid 🙂

And the explore you’re accessing is defined in the same model?

Is the view used in any other explores where the map layer isn’t defined? → this could also be a problem

Hi,

It’s Dawid 🙂

And the explore you’re accessing is defined in the same model?

Is the view used in any other explores where the map layer isn’t defined? → this could also be a problem

Well remembered. I'll check and let you know.

Hi,

It’s Dawid 🙂

And the explore you’re accessing is defined in the same model?

Is the view used in any other explores where the map layer isn’t defined? → this could also be a problem

Well remembered. I'll check and let you know.

Thank you very much Dawid (sorry I misspelled your name. 🙂

Your tip from explore was right. I managed to solve the problem.

I found that the visualization was being used in a test explorer where the map layer was not defined.

Now there are no more warning messages.

Thanks a lot for the support. And I hope soon to have knowledge so I can do the same as you did for me for the other members of the community. 🙂

Top Labels in this Space
Top Solution Authors