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
        })
    });

你可能感兴趣的:(OpenLayers)