Search code examples
javaswinganimationgisgeotools

animation on map with jmapframe - geotools


I am using geotools library to animate a polygon on a map. By using JMapPane it is possible to do animation smoothly. ex:AnimatedMapPane

However, the problem with it is that I can not use it with JMapFrame and I have to use JFrame. I want to use JMapFrame because it offers a lot more features compared JFrame like showing layers, zoom buttons etc.

Can I add JMapPane as a layer to JMapFrame? (A layer for map, another layer for animation objects)

In addition, I considered making dynamic layer to make animation. But as indicated here it causes flickering and answer suggests the usage of JMapPane.


Solution

  • Ideally you would extend JMapFrame and override the constructor to change the MapPane to be an AnimatedMapPane but mapPane is a private variable. If you put in an enhancement request (preferable with a clean up to use getMapPane() through out and a setMapPane(pane) method) I could review and apply it.

    Alternatively you could copy JMapFrame into a new class and make a single change to the type of MapPane created at line 202 and be done.