问题描述
您好,我正在Java中使用此示例尝试加载OpenStreetMaps离线图块,
Hello I'm using this sample in Java to try to load OpenStreetMaps Offline tiles,
例如,我在C:/OSM/tiles/
for example I have my tiles on C:/OSM/tiles/
但是我需要知道如何在地图(JMapViewer)类中添加此信息以在本地加载图块.
but I need to know how to add this information in map (JMapViewer) class to load tiles locally.
非常感谢您的帮助,这是我的消息来源:
Thank you very much for your help this is my source:
//License: GPL. Copyright 2008 by Jan Peter Stotz
import org.openstreetmap.gui.jmapviewer.JMapViewer;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
*
* Demonstrates the usage of {@link JMapViewer}
*
* @author Jan Peter Stotz
*
*/
public class Demo extends JFrame {
public Demo() {
super("JMapViewer Demo");
setSize(400, 400);
final JMapViewer map = new JMapViewer();
setLayout(new BorderLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setExtendedState(JFrame.MAXIMIZED_BOTH);
JPanel panel = new JPanel();
add(panel, BorderLayout.NORTH);
final JCheckBox showMapMarker = new JCheckBox("Map markers visible");
showMapMarker.setSelected(map.getMapMarkersVisible());
showMapMarker.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
map.setMapMarkerVisible(showMapMarker.isSelected());
}
});
panel.add(showMapMarker);
final JCheckBox showTileGrid = new JCheckBox("Tile grid visible");
showTileGrid.setSelected(map.isTileGridVisible());
showTileGrid.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
map.setTileGridVisible(showTileGrid.isSelected());
}
});
panel.add(showTileGrid);
final JCheckBox showZoomControls = new JCheckBox("Show zoom controls");
showZoomControls.setSelected(map.getZoomContolsVisible());
showZoomControls.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
map.setZoomContolsVisible(showZoomControls.isSelected());
}
});
panel.add(showZoomControls);
add(map, BorderLayout.CENTER);
//
// map.addMapMarker(new MapMarkerDot(49.814284999, 8.642065999));
// map.addMapMarker(new MapMarkerDot(49.91, 8.24));
// map.addMapMarker(new MapMarkerDot(49.71, 8.64));
// map.addMapMarker(new MapMarkerDot(48.71, -1));
// map.addMapMarker(new MapMarkerDot(49.807, 8.644));
map.setDisplayPositionByLatLon(-0.223056, -78.5126, 11);
}
/**
* @param args
*/
public static void main(String[] args) {
new Demo().setVisible(true);
}
}
推荐答案
我直接由源代码编译并更改
I compile by the source directly and change
这是JMapViewer.zip/JMapViewer_src.jar内的源代码,提取Jar文件,并将文件夹/org复制到邮件源代码文件夹中
Here is the source code inside JMapViewer.zip/JMapViewer_src.jar extract the Jar file and copy the folder /org in the mail source code folder
http://svn.openstreetmap. org/applications/viewer/jmapviewer/releases/2011-02-19/JMapViewer.zip
并更改下一个
public AbstractOsmTileSource(String name, String base_url, String attr_img_url) {
this.name = name;
// this.baseUrl = base_url;
this.baseUrl = "file:///C:/OSM/tiles";
attrImgUrl = attr_img_url;
}
这篇关于用于离线视图的JMapViewer ADD切片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!