感谢 tonio 的快速回复!
它现在可以与 OSM 一起使用 - 对于所有感兴趣的人,这是我的解决方案:(MY-MIDDLE-LAYER.KML 是德国地图,红色半透明用于测试目的)
var kml = new OpenLayers.Layer.GML("KML", "MY-MIDDLE-LAYER.KML", {
format: OpenLayers.Format.KML,formatOptions:{extractStyles:true,extractAttributes:true},alwaysInRange:true,isBaseLayer: false,opacity:50,transparent:true
});
OpenLayers.Layer.OSM.Toolserver = OpenLayers.Class(OpenLayers.Layer.OSM, {
initialize: function(name, options) {
var url = [
"http://a.www.toolserver.org/tiles/" + name + "/${z}/${x}/${y}.png",
"http://b.www.toolserver.org/tiles/" + name + "/${z}/${x}/${y}.png",
"http://c.www.toolserver.org/tiles/" + name + "/${z}/${x}/${y}.png",
"http://d.www.toolserver.org/tiles/" + name + "/${z}/${x}/${y}.png",
"http://e.www.toolserver.org/tiles/" + name + "/${z}/${x}/${y}.png",
"http://f.www.toolserver.org/tiles/" + name + "/${z}/${x}/${y}.png"
];
options = OpenLayers.Util.extend({numZoomLevels: 19}, options);
OpenLayers.Layer.OSM.prototype.initialize.apply(this, [name, url, options]);
},
CLASS_NAME: "OpenLayers.Layer.OSM.Toolserver"
});
l1=new OpenLayers.Layer.OSM.Toolserver('osm-labels-de', {isBaseLayer: false, visibility: true});
l2=new OpenLayers.Layer.OSM.Toolserver('osm-no-labels');
map.addLayers([kml,l1,l2]);
...并且标签在所有内容之上都非常易读:)