Java 以编程方式滚动JMapViewer映射
我有一个Java 以编程方式滚动JMapViewer映射,java,swing,jmapviewer,Java,Swing,Jmapviewer,我有一个JMapViewer作为JFrame上的面板和一个按钮。如果我按下按钮,我希望JMapViewer显示一个滚动的地图摘录 我试图通过lat/lon设置另一个显示位置,但我不知道如何获得旧的以地图为中心的lat/lon值 My Button Actionlistener,其中应显示略向上移动的地图摘录: btn_PanUp.addActionListener(new ActionListener(){ @Override public void actionPerform
JMapViewer
作为JFrame
上的面板和一个按钮。如果我按下按钮,我希望JMapViewer
显示一个滚动的地图摘录
我试图通过lat/lon设置另一个显示位置,但我不知道如何获得旧的以地图为中心的lat/lon值
My Button Actionlistener,其中应显示略向上移动的地图摘录:
btn_PanUp.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent arg0) {
jmv.setDisplayPositionByLatLon(lat+0.01, lon, zoom)
jmv.invalidate();
}
});
但我不知道如何获得地图中心的当前纬度/经度值。我如何获得它们 查看JMapViewer,有一个名为
getPosition()
的方法,它提供当前地图中心
资料来源:
/**
* Calculates the latitude/longitude coordinate of the center of the
* currently displayed map area.
*
* @return latitude / longitude
*/
public Coordinate getPosition() {
double lon = OsmMercator.XToLon(center.x, zoom);
double lat = OsmMercator.YToLat(center.y, zoom);
return new Coordinate(lat, lon);
}