简体   繁体   English

如何在JMapViewer的两个点之间放置箭头之类的图像

[英]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 point p2 ? 如何放置从点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 another LinkedList …the JMapViewer doesn't delete the MapPolygon . 删除MapPolygon …并创建另一个LinkedListJMapViewer不会删除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.

相关问题 在JMapViewer中的两个地理位置之间绘制线 - Draw Line between two Geo Points in JMapViewer JMapViewer绘制一个看起来像箭头的多边形 - JMapViewer draw a polygon that will look like arrow 如何在JMapViewer的特定坐标中加载图像? - How do I load an image in a particular coordinate in JMapViewer? Java JMapViewer:如何更改MapPolygon的颜色? - Java JMapViewer: How can I change the color of a MapPolygon? 如何计算Java中两个gps点之间的距离? - How can i calculate the distance between two gps points in Java? 如何清理面板中两点之间的线 - how can I clean the line between two points in a panel 如何在处理中计算两个给定点之间的点? - How can I calculate a point between two given points in processing? 如何从我的JMapViewer世界地图中获取鼠标点击位置 - how can i get the mouse click position from my JMapViewer world map 如何仅使用两个变量找到两点之间的距离,然后存储所有点并获得形状? - How can I find the distance between two points using only two variables and after that store all points and obtain the shape? 我如何在通过鼠标单击创建的两点之间绘制一条线 - How can i draw a line between two points created as a result of a mouse click
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM