好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

html5教程-Openlayers3加载天地图

小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

概述:

在前文中分别讲到了在Arcgis for js、O PE nlayers2中去加载天地图,同时也讲到了天地图的离线加载方式。在本文,讲述在Openlayers3中实现在线/离线的天地图的加载。

实现:

直接贴代码吧,效果就不贴了

body, # map { border: 0px; m arg in: 0px; padding: 0px; width: 100%; h ei ght: 100%; font- Size: 13px; } #map{ background: url(" .. /images/bg img .gif"); background-repeat: inher IT ; } <script type="text/javascript" src="plu gin /ol3/build/ol-debug.js"></script><script type="text/javascript" src="plugin/ jq uery/jquery-1.8.3.js"></script><script type="text/javascript"> VAR ma p; function init(){ var bounds = [73.4510046356223, 18.1632471876417, 134.976797646506, 53.5319431522236]; var PR ojection = new ol.proj.Projection({ code: 'EPSG:4326', units: ' deg rees' }); var vec_c = getTdtLayer("vec_c"); var cva_c = getTdtLayer("cva_c"); var wms = new ol.layer.Image({ source: new ol.source.ImageWMS({ ratio: 1, url: 'https://localhost:8088/geoserver/lzugis/wms', par am s: { 'FORMAT': 'image/png', 'VERSION': '1.1.1', LAYERS: 'lzugis:capital', STYLES: '' } }) }); var map = new ol. Map ({ controls: ol.control. defaults ({ attribution: false }), target: 'map', layers: [vec_c,cva_c,wms], view: new ol.View({ projection: projection, minZoom:2, maxZoom:8 }) }); map.getView().fitExtent(bounds, map.getSize()); } function getTdtLayer(lyr){ var url = "https://localhost:8081/lzugis/tdttile?T="+lyr+"&X={x}&Y={y}&L={z}"; // var url = "https://t0.tianditu .COM /DataServer?T="+lyr+"&X={x}&Y={y}&L={z}";在线 var projection = ol.proj.get("EPSG:4326"); var projectionExtent = [ -180, -90, 180, 90 ]; var maxResolution = (ol.extent.getWidth(projectionExtent) / (256 * 2)); var resolutions = new Array (16); var z; for (z = 0; z -t ileCoord[2]-1; var n = Math.pow(2, z + 1); x = x % n; if (x * n

概述:

在前文中分别讲到了在Arcgis for js、Openlayers2中去加载天地图,同时也讲到了天地图的离线加载方式。在本文,讲述在Openlayers3中实现在线/离线的天地图的加载。

实现:

直接贴代码吧,效果就不贴了

body, #map { border: 0px; margin: 0px; padding: 0px; width: 100%; height: 100%; font -s ize: 13px; } #map{ background: url("images/bgImg.gif"); background-repeat: inherit; } <script type="text/javascript" src="plugin/ol3/build/ol-debug.js"></script><script type="text/javascript" src="plugin/jquery/jquery-1.8.3.js"></script><script type="text/javascript"> var map; function init(){ var bounds = [73.4510046356223, 18.1632471876417, 134.976797646506, 53.5319431522236]; var projection = new ol.proj.Projection({ code: 'EPSG:4326', units: 'degrees' }); var vec_c = getTdtLayer("vec_c"); var cva_c = getTdtLayer("cva_c"); var wms = new ol.layer.Image({ source: new ol.source.ImageWMS({ ratio: 1, url: 'https://localhost:8088/geoserver/lzugis/wms', params: { 'FORMAT': 'image/png', 'VERSION': '1.1.1', LAYERS: 'lzugis:capital', STYLES: '' } }) }); var map = new ol.Map({ controls: ol.control.defaults({ attribution: false }), target: 'map', layers: [vec_c,cva_c,wms], view: new ol.View({ projection: projection, minZoom:2, maxZoom:8 }) }); map.getView().fitExtent(bounds, map.getSize()); } function getTdtLayer(lyr){ var url = "https://localhost:8081/lzugis/tdttile?T="+lyr+"&X={x}&Y={y}&L={z}"; // var url = "https://t0.tianditu.com/DataServer?T="+lyr+"&X={x}&Y={y}&L={z}";在线 var projection = ol.proj.get("EPSG:4326"); var projectionExtent = [ -180, -90, 180, 90 ]; var maxResolution = (ol.extent.getWidth(projectionExtent) / (256 * 2)); var resolutions = new Array(16); var z; for (z = 0; z 觉得 可用,就经常来吧! 欢迎评论哦!  html5教程 ,巧夺天工,精雕玉琢。小宝典献丑了!

总结

以上是 为你收集整理的 html5教程-Openlayers3加载天地图 全部内容,希望文章能够帮你解决 html5教程-Openlayers3加载天地图 所遇到的问题。

如果觉得 网站内容还不错, 推荐好友。

查看更多关于html5教程-Openlayers3加载天地图的详细内容...

  阅读:49次