2017-10-13 129 views
0

我想使用#jxmaps提取GPS坐标。为此我添加了两个JPanel。一个面板来保存几个按钮和文本字段,在其他面板我想添加MapView。我试过这个如何在JDialog的JPanel中添加MapView以及另一个JPanel

JPanel mypanel = new JPanel();//null; 
    JPanel mypanel2 = new JPanel(); 
    mypanel.setLayout(new BorderLayout(200,100)); 
    mypanel.setVisible(true); 
    mypanel.add(mapView, BorderLayout.CENTER); 
    JFrame frame = new JFrame("JxMaps - Hello, World!"); 
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 
    frame.add(mypanel, BorderLayout.CENTER); 
    frame.add(mypanel2, BorderLayout.EAST); 
    frame.setSize(700, 500); 
    frame.setLocationRelativeTo(null); 
    frame.setVisible(true); 

但它不工作。任何人都可以请指导我如何做到这一点?

问候 阿米尔

回答

0

不幸的是,提供源代码的一部分没有关于MapView的初始化信息。

我试着运行你的示例,它在我身边工作正常。

MapView mapView = new MapView(); 
mapView.setOnMapReadyHandler(new MapReadyHandler() { 
    @Override 
    public void onMapReady(MapStatus status) { 
     Map map = mapView.getMap(); 
     map.setCenter(new LatLng(35.91466, 10.312499)); 
     map.setZoom(2.0); 
    } 
}); 

你能解释一下你有什么错误的详细:我通过以下方式初始化的MapView?

相关问题