By intention, when the JMapPane is resized, the contents of the pane do not change [1]. So, as the application window gets narrower, content from the right-hand side is trimmed off.

An alternate GIS visualisation standard is to zoom the contents of the window to ensure the same mapping area is covered as the application size changes - see the video at [2].

Is there a simple setting that will force the second behaviour in GeoTool JMapPane ? Or, do I need to handle component resized, retrieve the previous data area, and force the map to display that area again?

[1]. http://docs.geotools.org/stable/userguide/unsupported/swing/jmappane.html#how-map-position-and-scale-are-calculated

[2]. https://youtu.be/lovWETSsXe4


As far as I know there is no handy switch for this. I think you would need to modify MapViewPort.calculateCenteringTransforms() to use your new method of calculation.

  • Thanks for that @ian-turton. Sadly that level of spatial intimidates me :-) – ianmayo Mar 15 '19 at 9:36

For anyone else after this feature, it has now been added into GeoTools here: https://github.com/geotools/geotools/pull/2324

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.