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

How to get viewPort of the result SVG? #35

Open
oyatek opened this issue Apr 19, 2024 · 6 comments
Open

How to get viewPort of the result SVG? #35

oyatek opened this issue Apr 19, 2024 · 6 comments

Comments

@oyatek
Copy link

oyatek commented Apr 19, 2024

It seems the script just returns an array of SVG paths.
How to get the viewPort of the result SVG? (taken from geoJSON)?

@gagan-bansal
Copy link
Owner

gagan-bansal commented Jun 17, 2024

@oyatek My apologies for late reply, by this time you would have solved your issue.

Actually viewPort size is passed as parameter when you create the instance of GeoJSON2SVG:

const {GeoJSON2SVG} = require('geojson2svg');

const converter = new GeoJSON2SVG({
  mapExtent: {left: -180, bottom: -90, right: 180, top: 90},
  viewportSize: {width: 200, height: 100},
  attributes: ['properties.class' , 'properties.foo'],
  r: 2
});`` 

@gagan-bansal
Copy link
Owner

Please reopen if issue is not resolved.

@oyatek
Copy link
Author

oyatek commented Sep 3, 2024

I mean that for example I have geoJSON of New York City and I need to get the coordinates of the bounding box (lat/lng coords) of the whole area. GeoJSON has all coordinates so technically it should be possible to find min/max coordinates, right? But maybe not been implemented in the library yet.

@gagan-bansal
Copy link
Owner

This feature is implemented, if parameter mapExtent is not provided then the paramter mapExtentFromGeojson would be considered as true and the extent of the data set (in lat/long - same as GeoJSON coordinates) would calculated internally. Please check here https://github.com/gagan-bansal/geojson2svg?tab=readme-ov-file#initializing-the-instance

viewportSize is also important parameter, in a simple way it is your HTML div (map div) size in pixels and default is {width: 256, height: 256} , most of the cases you need to change this.

If you put your example code, we can debug more.

Please read about mapExtent also, https://github.com/gagan-bansal/geojson2svg?tab=readme-ov-file#-important-points

In case you require to calculate the data set extent, you can use https://www.npmjs.com/package/geojson-bbox

@gagan-bansal gagan-bansal reopened this Sep 3, 2024
@oyatek
Copy link
Author

oyatek commented Sep 4, 2024

Thank you very much! I will try the suggested solution.

@gagan-bansal
Copy link
Owner

Sure, once your issue is resolved we'll close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants