2017-10-13 128 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?

相關問題