openlayers使用geoser的WMS协议

var layers = [
        new ol.layer.Tile({
            source: new ol.source.TileWMS({
                url: 'http://192.168.1.77:8080/geoserver/shptest/wms',
                params: {
                    'LAYERS': 'china'
                }
            })
        })
    ];

    var map = new ol.Map({
        controls: ol.control.defaults().extend([
            new ol.control.ScaleLine({
                units: 'degrees'
            })
        ]),
        layers: layers,
        target: 'map',
        view: new ol.View({
            projection: 'EPSG:4326',
            center: [100, 35],
            zoom: 5
        })
    });

转载自:https://blog.csdn.net/yangliu19920502/article/details/45847689

You may also like...