admin管理员组文章数量:1277901
I have a WMST service I want to show on a mapboxgl map. The following is an openlayers example: .html
Is there an example for MapBoxGLJS? Does it support TMS as well? I can't find any documentation or examples on this... am not sure if this is poorly documented or the feature just does not exist.
If the answer is no, that is an acceptable answer.
I have a WMST service I want to show on a mapboxgl map. The following is an openlayers example: https://openlayers/en/latest/examples/wms-time.html
Is there an example for MapBoxGLJS? Does it support TMS as well? I can't find any documentation or examples on this... am not sure if this is poorly documented or the feature just does not exist.
If the answer is no, that is an acceptable answer.
Share Improve this question edited Jun 16, 2017 at 4:57 Rolando asked Jun 15, 2017 at 21:22 RolandoRolando 62.7k104 gold badges279 silver badges422 bronze badges2 Answers
Reset to default 15Yes, you can use both WMS and tms in mapbox-gl.
The mapbox-gl WMS support is somewhat awkward, because mapbox-gl always uses tiled sources. So, for WMS, you have to retrieve your WMS data as tiles. If you need WMS-Time, you can add the &time= parameter to the WMS request.
TMS looks very much like the de-facto standard tile sets provided by Google, Bing, MapQuest, OpenStreetMap but they have the Y factor 'upside-down'. You can tell mapbox-gl that it should handle the y-factor differently by adding option: "scheme": "tms".
Example WMS source:
<!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./mapbox-gl-js/v0.37.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox./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>
For TMS you can use the same setup, but set "scheme":"tms" in the source section:
"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]
},
(Note that if you happen to use geoserver as a tms vector tile server, geoserver should be using a 512x512 grid)
Mapbox-GL-JS doesn't even support regular WMS, let alone WMS Time. If you look at the example for WMS, the whole URL is hardcoded.
Mapbox-GL-JS does not support TMS, which is a sort of metadata wrapper around the raw OSM tile serving conventions. Mapbox's equivalent is TileJSON.
本文标签: javascriptDoes MapboxGLJS support WMST andor TMSStack Overflow
版权声明:本文标题:javascript - Does MapboxGLJS support WMS-T andor TMS? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741287696a2370366.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论