Geographic Information Systems Asked by Cristina Monterisi on April 14, 2021
I tried to implement layers in WMS format in openlayers 6. This layer comes from the Geoportal of the Emilia Romagna region, but I cannot see it on the map. This is the code:
HTML:
<!doctype html>
<html lang="en">
<head>` <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/css/ol.css" type="text/css">
<script src="Prova2.js"></script>
<script src="https://unpkg.com/elm-pep"></script>
<style>
.map {
height: 800px;
width: 100%;
}
</style>
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/build/ol.js"></script>
<title>OpenLayers example</title>
</head>
The editor does not let me insert the code with the div containing the map on this page <div id="map" class="map"
, but there is in the code.
JAVASCRIPT:
window.onload = init;
function init() {
var layer2 = new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://servizigis.regione.emilia-romagna.it/wms/uso_del_suolo',
params: {
'LAYERS': '2017_uso_suolo_ed2020'
},
projection: "EPSG:4326",
/* serverType: 'geoserver',*/
}),
});
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}), layer2
],
view: new ol.View({
projection: "EPSG:4326",
center: [12.42125, 41.838481],
zoom: 7
})
})
}
I am a beginner.
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP