4

I'm working with OpenStreet Maps in Java with JMap Viwer http://wiki.openstreetmap.org/wiki/JMapViewer I can load the maps and everything ok but I don't know how to draw a line between two points from a latitude and longitude.

Any body know the function to draw this kind of lines?

Thank you.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045

2 Answers2

8

The addMapPolygon() method of JMapViewer works for this, but paintPolygon() silently rejects a polygon having fewer than three vertices. For a line between two points, just repeat the last Coordinate.

Coordinate one = new Coordinate(...);
Coordinate two = new Coordinate(...);
List<Coordinate> route = new ArrayList<Coordinate>(Arrays.asList(one, two, two));
map.addMapPolygon(new MapPolygonImpl(route));
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
0

I am also working on this software and using the JMapviewer.jar. Yet, I do not seem to have the addMapPolygon nor the MapPolygonImpl ... Is there a specific version I should be working with ? (I downloaded my version here: enter link description here

FireFox
  • 472
  • 2
  • 4
  • 14
  • 2
    Yes at fist I have the same problem (I was using the jar file) but I have replace the jar for the complete source, first download the copmlete Soruce from [HERE](http://svn.openstreetmap.org/applications/viewer/jmapviewer/src/) and put in the main source folder of your proyect like a /src/org look the last answer can help you [HERE](http://stackoverflow.com/questions/10657239/jmapviewer-add-tiles-for-offline-view), note: use SVN client to download the full source [I use this](http://tortoisesvn.tigris.org/) – Alejandro Quintanar May 28 '12 at 23:05
  • `svn info` shows _Revision: 28407_. Since this isn't an answer, you could delete it or pose it as a new question and accept aquintanar's answer? In either case, consider up-voting aquintanar's question as I have. – trashgod May 29 '12 at 02:57