I am currently working on a project that involves showcasing a map centered on a specific country and its neighboring countries using GeoJSON. I am curious if there is a way to determine the center point of only the visible portions of a country?
One aspect of this project includes labeling countries as markers. So far, I have been able to place the markers at:
- The center point of the country
- The center point of the visible bounding box
The first method often results in labels being displayed outside of the view or partially within it, while the second method is an improvement but can still lead to labels appearing in areas beyond the country's borders due to the simplicity of the bounding box area representation. Ideally, I would like to identify the clipped area of a shape in order to determine the center point for better label placement, but I am unsure of how to achieve this.