我在任何地方都找不到简单的答案,所以我想我遗漏了一些东西:
我在java中使用openstreetmap,我制作了一个GUI,当我点击的时候我得到了一个地理点,我想显示一个我点击的标记,我尝试过这样做,但是它不起作用:
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();有什么线索吗?
发布于 2016-08-03 07:30:33
因为您只是重写方法(paintWaypoint()),但没有修改该方法。
所以这对我有用,对你也有用.
将下列代码添加到您的paintWaypoint() .this中,将在鼠标位置上画一个十字标记(X)。
g.setColor(Color.RED);
g.drawLine(-5,-5,+5,+5);
g.drawLine(-5,+5,+5,-5);
return true;https://stackoverflow.com/questions/32778761
复制相似问题