How I can put an image that goes from point p1
to point 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
. But when I try to delete a MapPolygon
, that I created first, it's not work and I don't know why. 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
?
As shown in this example, you can add an arrow shaped MapPolygon
to your JMapViewer
using addMapPolygon()
.
After I delete a
MapPolygon
…and I create anotherLinkedList
…theJMapViewer
doesn't delete theMapPolygon
. 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. Use removeAllMapPolygons()
to completely clear()
the map viewer's internal list of polygons.
Addendum: Here's a concrete example illustrating addMapPolygon()
and 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);
}
}));