It sounds like you are reinventing the wheel.
You can use a WMS server (several work with TomCat, although the pier is usually used by default). A WMS server (see GeoServer or MapServer for the most popular open source examples) can receive data from your database and display it on demand on top of background images, that is, your world map or, possibly, OpenLayers.
In a WMS request, you can specify the image size and file format. This may be a little redundant for what you want, but they are pretty easy to set up (especially GeoServer).
If you have additional questions for this reason, https://gis.stackexchange.com/ , most likely you will receive additional information about the domain.
source share