How can I display a Map generated by GeoServer from a Java Mobile Application?
I would like to display it inside a Java App instead of a android application. Is this possible?
All you need to do is create a correct URL in your app and use Java to open the URL and fetch the contents as an image. The display the image as usual.
To determine what URL you need you should read the WMS specification, or if you are in a hurry crib one from the GeoServer examples page or any other web map you can find.
Geoserver is a Server based application that generates maps by sending tiles to a Client Application.
The two most Common Client Applications are Openlayers and Leaflet which rely on JavaScript to handle the presentation of the tiles to the end user on the Client.
JavaSE has the ScriptEngineManager (javax.script package) which can execute JavaScript, and the documentation on that can be see Here!
A simple example of its usage is as follows:
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
engine.eval("print('Hello, GIS World')");
You would need to ensure your mobile application in Java could support this engine, then implement either OpenLayers or Leaflet to handle the map display.
Caveats:
- OpenLayers and Leaflet assume you have a Browser available to display the maps
- I have not done this, I am not aware of anyone else who has
- I am not aware of any other solution
- This will be a LOT of work and effort to get working
Alternatively, if your Java Application on the phone used a Browser you could simply implement Openlayers or Leaflet as a normal implementation, provided that the browser met the minimum requirements.