java如何在JMapViewer中的两点之间放置像箭头一样的图像
如何将图像从点p1
放置到点p2
?有人能给我提个建议吗
Edit:我遵循这个例子Draw Line between two Geo Points in JMapViewer,在两个geoPoints
之间绘制一条路径。但是当我试图删除我首先创建的MapPolygon
时,它不起作用,我不知道为什么。输入是正确的,相信我
List<Coordinate> route = new ArrayList<Coordinate>(Arrays.asList(one, two, two));
List<MapPolygon> lista=cartina.getMapPolygonList();
MapPolygon arrow=new MapPolygonImpl(route);
cartina.removeMapPolygon(arrow);
编辑:我这样做:
private Coordinate one;
private Coordinate two;
public ExampleClass(Coordinate one, Coordinate two) {
this.one=one;
this.two=two;
}
public method (){ //click button
List<Coordinate> route = new ArrayList<Coordinate>(Arrays.asList(one, two, two));
map.addMapPolygon(new MapPolygonImpl(route));
}
public methodB(){// click anothe button
List<Coordinate> route = new ArrayList<Coordinate>(Arrays.asList(one, two, two));
map.removeMapPolygon()(new MapPolygonImpl(route));
}
# 1 楼答案
如图example所示,您可以使用
addMapPolygon()
将箭头形状的MapPolygon
添加到JMapViewer
中使用互补方法
removeMapPolygon()
删除MapPolygon
,但确保它是对添加的相同的MapPolygon
的引用,而不是对创建箭头时可能使用的LinkedList
的引用。使用removeAllMapPolygons()
完全clear()
地图查看器的内部多边形列表附录:这里有一个具体的例子来说明
addMapPolygon()
和removeMapPolygon()