我对Openlayers还是陌生的,并且正忙于投影。我尝试使用投影EPSG:3067创建地图,但是我的代码未显示任何内容。我的代码尝试使用库proj4js定义投影,并在openlayers地图中使用投影。代码没有给出任何错误,并且在openlayers文档中进行了长时间搜索之后,我仍然找不到错误。错误可能在哪里?
<script>
//Defining projection with proj4
proj4.defs('EPSG:3067','+proj=utm +zone=35 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
ol.proj.proj4.register(proj4);
//Creating projection to Openlayer
var projection = ol.proj.get('EPSG:3067');
//Defining extent and settingit to projection
var extent = [50199.4814, 6582464.0358, 761274.6247, 7799839.8902];
projection.setExtent(extent);
//Creating map
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
//Creating view for map
view: new ol.View({
projection: projection,
extent: extent,
zoom: 4
})
});
</script>