<body>
<div id="map"></div>
<script>
var extent = [0, 0, 1024, 968];//表示图片的尺寸
var projection = new ol.proj.Projection({
code: 'EPSG:3857',
extent: extent
});
var imageLayer = new ol.layer.Image({
source: new ol.source.ImageStatic({
url: 'image/online_communities.png',
projection: projection,
imageExtent: extent
})
});
var map = new ol.Map({ //初始化map
target: 'map',
layers: [
imageLayer
],
view: new ol.View({
projection: projection,
center: ol.extent.getCenter(extent),
zoom: 2
})
});
</script>
</body>