如何在 Openstreetmap 中突出显示 MapMarkerDot?

How can I highlight a MapMarkerDot in Openstreetmap?

我使用 http://svn.openstreetmap.org/applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java 中的代码制作了一张地图,并 运行 用于我的 swing 应用程序。

我添加了几个 MapMarkerDot 来指示地图中的一些点并使用了 how can i get the mouse click position from my JMapViewer world map to identify whether a point has been selected but how can I actually show that a particular MapMarkerDot has been selected? I want to add some kind of border similar to http://bikes.oobrien.com/london/#zoom=14&lon=-0.1155&lat=51.4992 但到目前为止我还没有看到成功。

非常感谢任何建议/参考。谢谢!

MapMarkerCirclepaint()MapMarkerDot 父实现忽略 Style 中指定的 Stroke,但您可以将 MapMarkerCircle 扩展为使用更大的 radius 渲染任何东西。在下面的示例中,Update 按钮侦听器显示了如何动态更改自定义标记的背景颜色。

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.util.Random;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JFrame;
import org.openstreetmap.gui.jmapviewer.Coordinate;
import org.openstreetmap.gui.jmapviewer.JMapViewer;
import org.openstreetmap.gui.jmapviewer.MapMarkerCircle;
import org.openstreetmap.gui.jmapviewer.MapMarkerDot;
import org.openstreetmap.gui.jmapviewer.Style;

/**
 * @see 
 */
public class London {

    private static final Random r = new Random();

    private void display() {
        JFrame f = new JFrame("London");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JMapViewer map = new JMapViewer() {

            @Override
            public Dimension getPreferredSize() {
                return new Dimension(320, 240);
            }
        };
        Coordinate london = new Coordinate(51.5072, -0.1275);
        map.setDisplayPosition(london, 16);
        MyMarker dot = new MyMarker("", london);
        map.addMapMarker(dot);
        map.addMapMarker(new MapMarkerDot("London", london));
        f.add(map);
        f.add(new JButton(new AbstractAction("Update") {

            @Override
            public void actionPerformed(ActionEvent e) {
                Style style = dot.getStyle();
                style.setBackColor(Color.getHSBColor(r.nextFloat(), 1f, 1f));
                style.setColor(Color.red);
                map.repaint();
            }
        }), BorderLayout.SOUTH);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    }

    private static class MyMarker extends MapMarkerCircle {

        public MyMarker(String name, Coordinate coord) {
            super(null, name, coord, 12, STYLE.FIXED, getDefaultStyle());
        }
    }

    public static void main(String[] args) {
        EventQueue.invokeLater(new London()::display);
    }
}