Question

I am trying to put a JMapViewer into a program I am doing and I want it to be centered in a specific area (Leicester, UK). Although I am not sure how the .setDisplayPosition function works and how I can use the co ordinates i have for it to do this task? Thanks.

Was it helpful?

Solution

Use JMapViewer#setDisplayPositionByLatLon() to zoom to a particular point.

Addendum: I don't have the method setDisplayPositionByLatLon().

Ah, the method was removed in r30244 in favor of setDisplayPosition().

Coordinate paris = new Coordinate(48.8567, 2.3508);
map.setDisplayPosition(paris, 8);

From the log:

$ svn log -r30244 src/org/openstreetmap/gui/jmapviewer/JMapViewer.java 
------------------------------------------------------------------------
r30244 | glebius | 2014-01-31 07:51:51 -0500 (Fri, 31 Jan 2014) | 3 lines

To match getPosition() and simplify code rename setDisplayPositionByLatLon()
into setDisplayPosition(Coordinate to, ...).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top