Draw Line between two Geo Points in JMapViewer

倾然丶 夕夏残阳落幕 提交于 2019-11-26 10:00:14

问题


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.


回答1:


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));



回答2:


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



来源:https://stackoverflow.com/questions/10744798/draw-line-between-two-geo-points-in-jmapviewer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!