我想在地图上显示我的服务。下面是一个开层示例:https://openlayers.org/en/latest/examples/wms-time.html
有MapBoxGLJS的例子吗?它也支持TMS吗?我找不到这方面的任何文件或例子.我不确定这是否有很好的文档记录,或者这个特性只是不存在。
如果答案是否定的,那是一个可以接受的答案。
发布于 2017-06-19 03:21:05
发布于 2017-06-19 22:20:37
是的,您可以在mapbox中同时使用WMS和tms。
mapbox支持有点尴尬,因为mapbox总是使用平铺源代码。因此,对于WMS,您必须以tiles的形式检索WMS数据。如果需要WMS-Time,可以将&time=参数添加到WMS请求中。
TMS看上去非常像Google、Bing、MapQuest、OpenStreetMap提供的事实上的标准瓷砖,但它们有“颠倒”的Y因素。您可以告诉mapbox,通过添加选项:“that”:"tms“,它应该以不同的方式处理y因子。
示例WMS来源:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id='map'></div>
<script>
var map = new mapboxgl.Map({
container: 'map', // container id
style: {
"version": 8,
"sources": {
"wms-tiles": {
"type": "raster",
"tiles": [
"https://geodata1.nationaalgeoregister.nl/luchtfoto/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&styles=default&layers=luchtfoto_jpeg"
],
"tileSize": 256
}
},
"layers": [{
"id": "aerial-photo",
"type": "raster",
"source": "wms-tiles",
"minzoom": 5,
"maxzoom": 22
}]
},
center: [5, 52.5], // starting position
zoom: 10 // starting zoom
});
</script>
</body>
</html>对于TMS,您可以使用相同的设置,但可以在源部分中设置“same”:“tms”:
"source": {
type: 'vector',
tiles:["http:/yourserver/geoserver/gwc/service/tms/1.0.0/yourendpoint/{z}/{x}/{y}.pbf"],
"scheme": "tms",
"minzoom": 13,
"maxzoom": 19,
"bounds": [3.38,50.73,7.2432,53.5455]
},(请注意,如果您碰巧使用geoserver作为tms矢量块服务器,geoserver应该使用512x512网格)
https://stackoverflow.com/questions/44577238
复制相似问题