【问题标题】:How I can put an image like an arrow between two points in JMapViewer如何在 JMapViewer 中的两点之间放置像箭头一样的图像
【发布时间】:2014-10-28 17:40:24
【问题描述】:

如何放置从点 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));
}

【问题讨论】:

  • 你可以为example绘制一个箭头形状的多边形。
  • @trashgod 感谢您的链接,它工作正常。但我还有一个问题。如果我在 MapPolygon 列表中添加一个 MapPolygon 并且在我删除一个 MapPolygon 并且我使用您链接我的算法并创建另一个 LinkedList 等... JMapViewer 不会删除 MapPolygon... 你知道为什么吗?添加 MapPolygonList 后如何删除 MapPolygon
  • 好问题;我已经详细说明了below;请更新您的问题以反映您的其他问题。

标签: java jmap jmapviewer


【解决方案1】:

如何放置一个从点p1 到点p2 的[箭头]?

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

在我删除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);
    }
}));

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2021-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-23
  • 1970-01-01
相关资源
最近更新 更多