I can't find a simple answer anywhere, so I guess I'm missing something:
I use openstreetmap in java, I made a GUI, I get a geopoint when clicking and I would like to display a marker where I clicked, I tried this but it doesn't work:
GeoPosition gp2 = map.convertPointToGeoPosition(map.getMousePosition());
Waypoint wp = new Waypoint() {
@Override
public GeoPosition getPosition() {
// TODO Auto-generated method stub
return gp2;
}
};
Set<Waypoint> set = null;
set.add(wp);
WaypointPainter<Waypoint> wpp = new WaypointPainter<Waypoint>();
wpp.setRenderer(new WaypointRenderer<Waypoint>() {
@Override
public void paintWaypoint(Graphics2D g, JXMapViewer map, Waypoint waypoint) {
// TODO Auto-generated method stub
}
});
wpp.setWaypoints(set);
Map.this.getJXMapViewer().setOverlayPainter(wpp);
Map.this.getJXMapViewer().revalidate();
Map.this.getJXMapViewer().repaint();
any clue why?
because you just Override the method (
paintWaypoint()
) ,but you didn't modify the method.so this works for me and will works for you also....
add following codes into your
paintWaypoint()
.this will draw a cross mark (X) on your mouse position.