Trying to center a map in canvas

I´m trying to centralize a map base in a chosen city. I´ve succesfully create two filters state and city to filter a map. After applying the filter the map displays only the city however I can´t define the latitude and longitude automatically and it is very hard to find the city. I have latitude and longitude in the same index as the map (mapa_cidades_brasil), but I´m unable to use the data from the table to centralize the map. I tried:

filters group="CIDADE" ungrouped=true
| esdocs index="mapa_brasil_cidades*"
fields="uf.keyword, nome.keyword, populacao, tx_wifi, vel_med, latitude, longitude" sort=", asc"
| alterColumn column="latitude" type="number"
| alterColumn column="longitude" type="number"
| savedMap id="4cc6bec0-5e41-11ea-87b6-cb7f060ff65e" center={mapCenter lat="latitude" lon="longitude" zoom=7.16} timerange={timerange from="now-15m" to="now"}
| render as="debug"

However, I can´t set latitude and longitude (center of the city) as parameters in the map.

Anyone able to help?

Hi @flaviogoncalves,

It looks like you might be missing the getCell function to pass the relevant input to mapCenter. Currently you have:

mapCenter lat="latitude" lon="longitude" zoom=7.16

This is passing the literal string values "latitude" and "longitude" as arguments to the mapCenter function. Most likely what you are trying to do is something like this:

mapCenter lat={getCell column="latitude"} lon={getCell column="longitude"} zoom=7.16

This will look up the columns from the tabular data provided as context to the function.

Does this work for you? Let me know!

Cheers -

Luke

Thanks for your reply,

I´ve tried but got the following error:

[savedMap] > Cannot read property 'map' of undefined

The easiest way would be to have a feature in the map to autocenter. Get the lowest and highest latitude and longitude of the objects selected to center and zoom accordingly.

Another interesting aspect is the coordinates adjust in real time whenever you move the map.

The easiest way would be to have a feature in the map to autocenter. Get the lowest and highest latitude and longitude of the objects selected to center and zoom accordingly.

Yeah I agree, that'd be a helpful feature. I was going to point you to an enhancement request for maps to add this in Github but I was happy to discover you have already joined the conversation there :smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.