[英]How I can put an image like an arrow between two points in JMapViewer
How I can put an image that goes from point p1
to point p2
? 如何放置从点
p1
到点p2
的图像? Anyone can suggest a way to me? 有人可以建议我吗?
Edit: I follow this example, Draw Line between two Geo Points in JMapViewer , to draw a path between two geoPoints
. 编辑:我遵循此示例,即在JMapViewer中的两个地理位置之间绘制线 ,以在两个
geoPoints
之间绘制路径。 But when I try to delete a MapPolygon
, that I created first, it's not work and I don't know why. 但是,当我尝试删除首先创建的
MapPolygon
,它不起作用,我也不知道为什么。 The input is correct, trust me! 输入正确,请相信我!
List<Coordinate> route = new ArrayList<Coordinate>(Arrays.asList(one, two, two));
List<MapPolygon> lista=cartina.getMapPolygonList();
MapPolygon arrow=new MapPolygonImpl(route);
cartina.removeMapPolygon(arrow);
Edit: I do this: 编辑:我这样做:
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));
}
How I can put an [arrow] that goes from point
p1
to pointp2
?如何放置从点
p1
到点p2
的[箭头]?
As shown in this example , you can add an arrow shaped MapPolygon
to your JMapViewer
using addMapPolygon()
. 如本示例所示,您可以使用
addMapPolygon()
将箭头形状的MapPolygon
添加到JMapViewer
。
After I delete a
MapPolygon
…and I create anotherLinkedList
…theJMapViewer
doesn't delete theMapPolygon
.删除
MapPolygon
…并创建另一个LinkedList
,JMapViewer
不会删除MapPolygon
。 Do you know why?你知道为什么吗?
Use the complementary method removeMapPolygon()
to remove a MapPolygon
, but be sure that it's a reference to the same MapPolygon
that you added and not a reference to a LinkedList
you might have used while creating the arrow. 使用补充方法
removeMapPolygon()
删除MapPolygon
,但是请确保它是对您添加的相同 MapPolygon
的引用,而不是对您在创建箭头时可能使用的LinkedList
的引用。 Use removeAllMapPolygons()
to completely clear()
the map viewer's internal list of polygons. 使用
removeAllMapPolygons()
完全clear()
地图查看器的内部多边形列表。
Addendum: Here's a concrete example illustrating addMapPolygon()
and removeMapPolygon()
. 附录:这是一个具体示例,说明
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);
}
}));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.