Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] Auto adjust map center and zoom when filtering map #53831

Closed
prashant-jain opened this issue Dec 28, 2019 · 20 comments
Closed

[Maps] Auto adjust map center and zoom when filtering map #53831

prashant-jain opened this issue Dec 28, 2019 · 20 comments
Labels
[Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation enhancement New value added to drive a business result v7.10.0

Comments

@prashant-jain
Copy link

prashant-jain commented Dec 28, 2019

I want to change center lat/long and zoom level to highlight select location in filters and default lat/long and zoom level in absence of any filter values.

I am showing some KPIs on map.

Screenshot 2019-12-28 at 4 45 58 PM

Now, When i use the filter to show KPIs on perticular area only.

Actual Result
Screenshot 2019-12-28 at 4 49 57 PM
This is showing kpis on selected region but without zooming in or highlighting the area in complete window.
Expected Result
Screenshot 2019-12-28 at 4 59 41 PM
I want to make this area auto zoom in (like fit to data functionality) and zoom out in case of absence of any filter.

Kibana Version:
7.5.1

OS:
Cent OS 7

Browser:
Google Chrome 79.0.3945.88

@nreese nreese added enhancement New value added to drive a business result [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation and removed Project:Accessibility labels Jan 5, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-gis (Team:Geo)

@nreese nreese changed the title Unable to change center lat/long and zoom level using filter variables. (Accessibility) Auto adjust map center and zoom when filtering map Jan 5, 2020
@thomasneirynck thomasneirynck changed the title Auto adjust map center and zoom when filtering map [Maps] Auto adjust map center and zoom when filtering map Jan 22, 2020
@flaviogoncalves
Copy link

Any progress on this feature?

@nreese
Copy link
Contributor

nreese commented Mar 24, 2020

Any progress on this feature?

There have been no PR made for this enhancement request

@flaviogoncalves
Copy link

I have a map of the whole country, cities and districts, when someone filters an specific city, he has to manually pan and zoom to find the city filtered, making the aplication useless. The "Fit to data" feature was disabled when you have geo_shapes, it is only active for geo_points. I tried with canvas to pass the center and zoom to a map to manually centralize, but the center and zoom are auto-adjustable. To make things worse, it is not possible even to pass a default center and zoom, so if someone zooms to a city, in the next day he has dicover where he is and to manually adjust to another city. I think maps is great, there are amazing things you can do, it is a great work. Unfortunately, I will have to start from scratch in the vizualizations using another tool.

@thomasneirynck
Copy link
Contributor

thomasneirynck commented Mar 24, 2020

hi @flaviogoncalves

fitting to shapes is currently blocked by the absence of the geo_bounds aggregation for geo_shape-fields. This is actively being worked on at the Elasticsearch side: elastic/elasticsearch#37206

This issue here is similar to #29991, which is blocked for the same reason.

We hope can close the loop on these features soon. Thank you for your patience! :)

@thomasneirynck
Copy link
Contributor

wrt:

it is not possible even to pass a default center and zoom, so if someone zooms to a city

Can you explain a little bit more in detail on how you would like to see this work? (maybe open a different ER for this). Right now, the zoom/center is saved when pressing the "save" button in the Maps-app. Is that not sufficient?

@flaviogoncalves
Copy link

I´m surprised,

What I was trying to do is whenever I select a city I have the coordinates of the center of that city. I wanted to set in the map these coordinates using canvas. However, when I change the position in canves it changes automagically the center of the map in the expression editor

center={mapCenter lat=-8.39467 lon=-58.55689 zoom=3.48}

You can reproduce this easily. Embed a map in canvas, open the expression editor and move the map, the center changes. Next time it will open in the last change.

@flaviogoncalves
Copy link

Should I open a feature request or new issue?

@nreese
Copy link
Contributor

nreese commented Mar 24, 2020

@flaviogoncalves can you open a new issue, specifically with canvas not preserving changes to map center.

@thomasneirynck
Copy link
Contributor

A short update on this. Starting 7.8, Maps has a fit2data button on the top-left hand side. Clicking this, the map will zoom to the extent of the data (with filters/queries applied).

@TimJMartin
Copy link

@thomasneirynck I have got the fit2data button working in my canvas project, but like other people have mentioned a user has to specifically press that button. For example I have over 2 million geojson features and wanted the user to pick a feature from the dropdown filter and the map filter (which is does) and then zoom to that single feature.

Is there a way to trigger this by an Expression, maybe render, or an alternative method?

@thomasneirynck
Copy link
Contributor

thx @TimJMartin for the added context. There is no immediate work-around that comes to mind here.

I do agree that requiring the user to explicitly click on the fit2data button is not ideal. For your use case, like in those kiosk-like apps with Canvas, a user would really prefer the auto-fitting to be automated.

@nreese created a POC for this functionality #66452

cc @kmartastic

@kmartastic
Copy link
Contributor

The default behavior for every map should be to zoom to the bounds of the visible data. To be dramatic, I would die on this hill.
If all data is filtered, we could debate if you zoom to the full extent of the world, just leave the extent as-is, or based on the full extent of the filtered data. My strong opinion, loosely held, is to leave the map as-is.

If we have the fit to data button, I assume we can do this automatically.

Beyond that, we should have an option to make layers "contextual" -- which basically treats them like a background map layer.

@flaviogoncalves
Copy link

Sorry to get in the thread, I had lot of expectations in the new feature. If we could at least fit to data on line strings and polygons, it is acceptable. The problem is when a user press the fit to data and nothing happens because it is a polygon map. The user is lost and don't understand what is happening.

@thomasneirynck
Copy link
Contributor

thomasneirynck commented Jul 1, 2020

@flaviogoncalves

wrt

The problem is when a user press the fit to data and nothing happens because it is a polygon map.

This manual-fit-to-data-bounds button is available in Kibana Maps starting 7.8. It will work both for layers with a geo_point field and for layers with a geo_shape field. In 7.8, Elasticsearch added geo_bounds-agg support for geo_shape fields (cf. elastic/elasticsearch#37206 (comment), making this now possible in Kibana.

@flaviogoncalves
Copy link

I've upgraded to 7.8 last week, but the button is still grayed out in the layers with polygons and line strings. I may be doing something wrong.

image

@thomasneirynck
Copy link
Contributor

hi @flaviogoncalves , thx for sharing :)

This is likely because your index containing that geo_shape field was indexed before 7.8.

To enable the "Fit to data" button, the geo_shape needs to be indexed with doc_values, which are only supported starting 7.8 for geo_shape in Elasticsearch.

So it would require you to re-index that shape data in 7.8. doc_values should be enabled by default then, and that fit-to-data button will become clickable.

@flaviogoncalves
Copy link

Thank you very much, I will try.

@TimJMartin
Copy link

@flaviogoncalves I have 2.5 million polygons as geo_shape and the fit to data button works, this was a brand new index I created yesterday using 7.8

@kmartastic totally agree about the default behaviour, I would also just leave the map as is, if there is no data left after a filter.

@nreese
Copy link
Contributor

nreese commented Jul 20, 2020

Closed by #72129

@nreese nreese closed this as completed Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation enhancement New value added to drive a business result v7.10.0
Projects
None yet
Development

No branches or pull requests

8 participants