1 year ago

#335825

test-img

HUARAZ - PERU

Geoserver and openlayer: why my map doesn't show when I run file:///C:/Users/nedam247/Desktop/open%20layer/prueba1.html?

I used apache-tomcat to run geoserver,then I used a shapefile called NEIGHBOURHOOD, this file has data for north America and south America, geoserver shows perfectly both data, but when I use open layer syntax in a html file and change the url and layer name inside the syntax, only shows the north America data and south America data doesn`t show. Please help me.

here is the code:

    <!DOCTYPE html>
<html>
  <head>
    <title>Tiled WMS</title>
    <link rel="stylesheet" href="https://openlayers.org/en/v4.6.5/css/ol.css" type="text/css">
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
    <script src="https://openlayers.org/en/v4.6.5/build/ol.js"></script>
  </head>
  <body>
    <div id="map" class="map"></div>
    <script>
      var layers = [
        new ol.layer.Tile({
          source: new ol.source.OSM()
        }),
        new ol.layer.Tile({
          extent: [-13884991, 2870341, -7455066, 6338219],
          source: new ol.source.TileWMS({
            url: 'http://localhost:8080/geoserver/geo585/wms',
            params: {'LAYERS': 'geo585:Neighborhoods', 'TILED': true},
            serverType: 'geoserver',
            // Countries have transparency, so do not fade tiles:
            transition: 0
          })
        })
      ];
      var map = new ol.Map({
        layers: layers,
        target: 'map',
        view: new ol.View({
          center: [-10997148, 4569099],
          zoom: 4
        })
      });
    </script>
  </body>
</html>

geoserver image

geoserver image

syntax openlayer, I changed the url and layer name according to geoserver

syntax openlayer, I changed the url and layer name according to geoserver

I opened in local browser the html file

I opened in local browser the html file

tomcat

geoserver

tile

wms

0 Answers

Your Answer

Accepted video resources