如何将图像从点p1
放到点p2
?任何人都可以向我推荐一种方式吗?
修改:我按照此示例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));
}
答案 0 :(得分:2)
如何设置从
p1
点到p2
点的[箭头]?
如此example所示,您可以使用MapPolygon
向JMapViewer
添加addMapPolygon()
形状的箭头。
删除
MapPolygon
后,我又创建了另一个LinkedList
...JMapViewer
并未删除MapPolygon
。你知道为什么吗?
使用补充方法removeMapPolygon()
删除MapPolygon
,但请确保它是对您添加的相同 MapPolygon
的引用, 不对您在创建箭头时可能使用过的LinkedList
的引用。使用removeAllMapPolygons()
完全clear()
地图查看器的内部多边形列表。
附录:这是一个说明addMapPolygon()
和removeMapPolygon()
的具体示例。
List<Coordinate> route = new ArrayList<>(Arrays.asList(one, two, three));
final MapPolygonImpl mapPolygon = new MapPolygonImpl(route);
map.addMapPolygon(mapPolygon);
toolBar.add(new JButton(new AbstractAction("Remove") {
@Override
public void actionPerformed(ActionEvent e) {
map.removeMapPolygon(mapPolygon);
}
}));