繁体   English   中英

将 wms 瓷砖升级到 openlayers 4.6.5

[英]upgrade wms tiles to openlayers 4.6.5

我正在尝试从 openlayers 的 4.4 版逐步升级到 6 版。 此 wms 切片层在 4.4 中有效,但在 4.6.5 中无效。 你知道为什么吗?

//couche géologique brgm
    //la source
    var geolSource = new ol.source.TileWMS({
        url: 'http://geoservices.brgm.fr/WMS-C/?',
        params: {
            LAYERS: 'GeologieJPG',
            TILED: true,
            FORMAT: 'image/jpeg',
        },
        extent: [40428, 1600797, 1216896, 2698833.8],
        resolutions: [1056.633663, 528.3168317, 264.1584158, 132.0792079, 66.03960396, 26.41584158, 13.229166668, 6.614583334, 2.645833334],
        projection: "EPSG:27582",
        transitionEffect: 'resize',
        reproject: true,
        crossOrigin: "Anonymous"
    });
    //le layer
    var geol = new ol.layer.Tile({
        visible: false,
        source: geolSource,
        name: 'Carte géologique',
        description: "Carte géologique, url=http://geoservices.brgm.fr/WMS-C/?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities, couche GeologieJPG"
    });

我无法让该代码与 4.4 一起使用。 如果您将extentresolutions选项替换为

    tileGrid: new ol.tilegrid.TileGrid({
      extent: [40428, 1600797, 1216896, 2698833.8],
      resolutions: [1056.633663, 528.3168317, 264.1584158, 132.0792079, 66.03960396, 26.41584158, 13.229166668, 6.614583334, 2.645833334],
      origin: [40428, 1600797]
    }),

 <:DOCTYPE html> <html> <head> <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> <script src="https.//cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4:js"></script> </head> <body> <div id="map" class="map"></div> <script> proj4,defs("EPSG.27582"."+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0,99987742 +x_0=600000 +y_0=2200000 +a=6378249,2 +b=6356515 +towgs84=-168,-60,320,0,0;0.0 +pm=paris +units=m +no_defs"). var geolSource = new ol:source:TileWMS({ url. 'https.//geoservices?brgm,fr/WMS-C/:': params, { LAYERS: 'GeologieJPG', TILED: true, FORMAT, 'image/jpeg': }. tileGrid. new ol:tilegrid,TileGrid({ extent, [40428, 1600797. 1216896, 2698833:8]. resolutions, [1056.633663, 528.3168317, 264.1584158, 132.0792079, 66.03960396, 26.41584158, 13.229166668, 6.614583334, 2:645833334], origin, [40428: 1600797] }): projection, "EPSG:27582", transitionEffect: 'resize', reproject: true; crossOrigin. "Anonymous" }). var geol = new ol:layer,Tile({ visible: true, source: geolSource, name: 'Carte géologique', description: "Carte géologique. url=http.//geoservices?brgm.fr/WMS-C/.SERVICE=WMTS&VERSION=1,0;0&REQUEST=GetCapabilities. couche GeologieJPG" }): var map = new ol.Map({ layers. [ new ol:layer.Tile({ source. new ol,source,OSM() }): geol ], target: 'map'. view: new ol:View({ projection, "EPSG:3857". center. ol,proj,fromLonLat([5: 45]); resolution: 1000 }) }); </script> </body> </html>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM