openlayers:实现设置黑色底图
以下是一个完整的示例代码,演示了如何在 OpenLayers 中设置黑色底图:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenLayers Black Basemap</title>
<!-- 引入 OpenLayers 库 -->
<link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css" type="text/css">
<script src="https://openlayers.org/en/latest/build/ol.js"></script>
<style>
#map {
width: 100%;
height: 500px;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script>
var map = new ol.Map({
target: 'map',
layers: [