1

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.

broliverparker
  • 217
  • 2
  • 15

1 Answers1

3

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, ...).
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • I don't have the method 'setDisplayPositionByLatLon' for some reason – broliverparker Apr 01 '14 at 15:23
  • Sorry, I had an older revision; more above. – trashgod Apr 01 '14 at 21:05
  • @ trashgod: I am having some troubles with raster data in JMapViewer. May I kindly ask for your assistence. Thank you very much: https://stackoverflow.com/questions/44955859/jmapviewer-load-raster-to-a-position – justik Jul 07 '17 at 09:52