0

我已经使用 JMapViewer 类在 Java GUI 中加载了 OSM 地图,并添加了一个搜索框和一个按钮。如何使用 ButtonClick 上的字符串输入搜索位置?这是我到目前为止所做的,请告诉我我做错了什么或者我应该怎么做?

private final JTextField searchText;
searchText= new JTextField(20);  
JButton go=new JButton("Go!!");
        go.addActionListener(new ActionListener()
                {
                    public void actionPerformed(ActionEvent e)
                    {
                        String query=searchText.getText();




                       Coordinate p = JMapViewer.getPosition(SearchAction.search(query));
                         LayerGroup search=new LayerGroup("Search");
                        Layer searchGroup=search.addLayer("Search Layer");
                          String res= map().getName();
                        double latpos=p.getLat();
                          double lonpos=p.getLon();
                         MapMarkerDot show=new MapMarkerDot(searchGroup,query,latpos,lonpos);

                    }

            private String search(String query) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            private String searchAction(String query) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

                });
4

0 回答 0