3

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?

1

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.

  • This is a great idea if you just want a static image, had not thought of that before, could be used in static web sites to display any map and you could us JS to randomly change the location. (Kind of like a map slide show) Of course, you don't get all the pan, zoom, etc options .. – Mark Cupitt Oct 3 '14 at 2:51
  • 1
    Well you'd need some code to change the bounding box as the user panned and zoomed anyway. – Ian Turton Oct 3 '14 at 7:12
0

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:

  1. OpenLayers and Leaflet assume you have a Browser available to display the maps
  2. I have not done this, I am not aware of anyone else who has
  3. I am not aware of any other solution
  4. 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.

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.