gpt4 book ai didi

java - 如何在 JMapViewer 中的两点之间放置像箭头一样的图像

转载 作者:行者123 更新时间:2023-11-30 03:42:26 28 4
gpt4 key购买 nike

如何放置从点 p1 到点 p2 的图像?有人可以给我建议一个方法吗?

编辑:我按照这个例子,Draw Line between two Geo Points in JMapViewer ,在两个地理点之间绘制一条路径。但是当我尝试删除我首先创建的 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));
}

最佳答案

How I can put an [arrow] that goes from point p1 to point p2?

example所示,您可以使用 addMapPolygon() 将箭头形状的 MapPolygon 添加到您的 JMapViewer

After I delete a MapPolygon…and I create another LinkedList…the JMapViewer doesn't delete the MapPolygon. Do you know why?

使用补充方法 removeMapPolygon() 删除 MapPolygon,但请确保它是对相同 MapPolygon 的引用 您添加的,不是 对您在创建箭头时可能使用的 LinkedList 的引用。使用 removeAllMapPolygons() 完全clear() map 查看器的内部多边形列表。

附录:这是一个具体示例,说明 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);
}
}));

关于java - 如何在 JMapViewer 中的两点之间放置像箭头一样的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26532511/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com