Java 如何在JMapViewer中以特定坐标加载图像?

Java 如何在JMapViewer中以特定坐标加载图像?,java,jmapviewer,Java,Jmapviewer,我正在尝试在JMapViewer中的特定坐标中加载图像。任何人都可以建议我使用什么类或提供一个小例子吗 package geovista.jmapviewer; //License: GPL. Copyright 2008 by Jan Peter Stotz import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.awt.image.

我正在尝试在JMapViewer中的特定坐标中加载图像。任何人都可以建议我使用什么类或提供一个小例子吗

   package geovista.jmapviewer;

//License: GPL. Copyright 2008 by Jan Peter Stotz

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import javax.imageio.ImageIO;

import geovista.jmapviewer.interfaces.TileCache;
import geovista.jmapviewer.interfaces.TileSource;

/**
 * Holds one map tile. Additionally the code for loading the tile image and
 * painting it is also included in this class.
 *
 * @author Jan Peter Stotz
 */
public class Tile {

    /**
     * Hourglass image that is displayed until a map tile has been loaded
     */
    public static BufferedImage LOADING_IMAGE;
    public static BufferedImage ERROR_IMAGE;

    static {
        try {
            LOADING_IMAGE = ImageIO.read(JMapViewer.class.getResourceAsStream("images/hourglass.png"));
            ERROR_IMAGE = ImageIO.read(JMapViewer.class.getResourceAsStream("images/error.png"));
        } catch (Exception e1) {
            LOADING_IMAGE = null;
            ERROR_IMAGE = null;
        }
    }

你被困在哪里?图像IO?布局坐标?当前版本为。
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;

import org.openstreetmap.gui.jmapviewer.Coordinate;
import org.openstreetmap.gui.jmapviewer.MapMarkerCircle;
import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker;

/**
 * @author wellsantos@wellsantos.com
 * @created 18/09/2014
 */
public class IconMarker extends MapMarkerCircle implements MapMarker {

    private Image image;

    public IconMarker(Coordinate coord, Image image) {
        this(coord, 1, image);
    }

    public IconMarker(Coordinate coord, double radius, Image image) {
        super(coord, radius);
        this.image = image;
    }

    @Override
    public void paint(Graphics g, Point position, int radio) {
        double r = this.getRadius();
        int width = (int) (this.image.getWidth(null) * r);
        int height = (int) (this.image.getHeight(null) * r);
        int w2 = width / 2;
        int h2 = height / 2;
        g.drawImage(this.image, position.x - w2, position.y - h2, width, height, null);
        this.paintText(g, position);
    }

    public Image getImage() {
        return this.image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

}


// ...... main

    JMapViewer mapViewer = new JMapViewer();
    this.setLayout(new BorderLayout());
    this.add(this.mapViewer, BorderLayout.CENTER);

    List<MapMarker> mapMarkerList = new ArrayList<MapMarker>();
    mapMarkerList.add(new IconMarker(new Coordinate(0.5, 0.5), this.image));
    this.mapViewer.setMapMarkerList(mapMarkerList);