0

我想使用#jxmaps 提取 GPS 坐标。为此,我添加了两个 JPanel。一个面板可以容纳几个按钮和文本字段,而在另一个面板中我想添加 MapView。我试过这个

    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); 

但它不起作用。谁能指导我如何做到这一点?

问候阿米尔

4

1 回答 1

0

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

我尝试运行您的示例,它在我这边工作正常。我用以下方式初始化了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);
   }
});

你能更详细地解释你有什么错误吗?

于 2017-10-14T07:46:28.437 回答