1
我試圖用OpenLayers 3在OpenStreetMap上顯示一些圓圈。地圖顯示正確,但是我沒有看到任何圓圈,也沒有得到JavaScript錯誤。我正在使用以下代碼:圓圈圖層不顯示在OpenLayers 3
<div id="map" class="map"></div>
<script type="text/javascript">
var circle = new ol.geom.Circle({
center: [-2.59394, 51.45271],
radius: 10
})
circle.transform('EPSG:4326', 'EPSG:3857');
var congestionLayer = new ol.layer.Vector({
source: new ol.source.Vector({
features: [new ol.Feature({
geometry: circle
})]
}),
style: new ol.style.Style({
fill: new ol.style.Fill({
color: "#000000"
})
}),
visible: true
})
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
congestionLayer
],
view: new ol.View({
center: ol.proj.fromLonLat([-2.59394, 51.45271]),
zoom: 10
})
});
</script>
我在做什麼錯?