f5 / unovis

Modular data visualization framework for React, Angular, Svelte, Vue, and vanilla TypeScript or JavaScript
https://unovis.dev
Apache License 2.0
2.07k stars 43 forks source link

Programmatically zoom to Area #430

Open Rkallenkoot opened 3 weeks ago

Rkallenkoot commented 3 weeks ago

Currently trying to figure out a way to Zoom to an Area programmatically and running into some issues. It seems that Unovis is dealing with all the different layers, TopoJSON / GeoJSON and d3 in the background, but I cannot figure out a way to do this.

Is there a chance we can add this feature in the TopoMap component?

An example would be to click on a country/area and zoom + center the map to this. Is this currently possible?

rokotyan commented 3 weeks ago

@Rkallenkoot Zooming to a specific area is not yet supported by TopoJSONMap, although I agree that it would be a nice feature to have. At the same time, I'm not sure how useful it will be, since TopoJSON maps are schematic and typically don't provide detailed views. Can you tell us more about the problem you're trying to solve with this feature?

Rkallenkoot commented 3 weeks ago

Thanks for the response! My current use-case is to display a statistic per Area. Some countries / islands (example: Caribbean islands) are so small that you can't see them unless zoomed in quite a bit. I'm displaying the exact stats in a table next to the Map, the user can click on the "Country" and I'd like to center the map around this Country with some additional Zoom. It would also be nice to be able to programmatically reset the center and zoom.