var map;
function init(){
map = new OpenLayers.Map( 'map',{
numZoomLevels:19
});
var wmts = new OpenLayers.Layer.WMTS({
name: "My WMTS Layer",
//url: "http://example.com/wmts",
url:"http://t0.tianditu.com/vec_c/wmts",
layer: "vec",
style: "default",
matrixSet: "c",
//matrixIds: matrixIds,
format:"tiles",
//opacity:1,
//maxZoomLevel:19,
isBaseLayer:true
});
//map.addLayers([osm,layer]);
map.addLayer(wmts);
map.setCenter(new OpenLayers.LonLat(115.86, 34.4), 12);
//map.addControl( new OpenLayers.Control.LayerSwitcher() );
//map.zoomToMaxExtent();
}
开始忘记设置map的numZoomLevels属性,导致ol源码中zoom = Math.max(0, Math.min(zoom, this.resolutions.length - 1));this.resolutions.length=undefined