本文介绍了在JMapViewer中绘制两个地理点之间的直线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JMap Viwer的Java OpenStreet Maps 我可以加载地图,一切正常,但我不知道如何在纬度和经度两点之间画一条线。

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?

谢谢。

推荐答案

addMapPolygon()方法 JMapViewer 适用于此,但 paintPolygon ()以静默方式拒绝具有少于三个顶点的多边形。对于两点之间的一条线,只需重复最后一个坐标

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

这篇关于在JMapViewer中绘制两个地理点之间的直线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 16:28