Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw Line between two Geo Points in JMapViewer

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.

like image 967
Alejandro Quintanar Avatar asked Feb 21 '23 08:02

Alejandro Quintanar


1 Answers

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));
like image 53
trashgod Avatar answered Feb 22 '23 22:02

trashgod