[英]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 一起使用。 如果您將extent
和resolutions
選項替換為
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.