本文主要是介绍基于openlayers3调用来自geoserver的切片地图服务,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
基于openlayers3调用来自geoserver的切片地图服务
<!DOCTYPE html>
<html><head><title>Simple Map</title><link rel="stylesheet" href="https://openlayers.org/en/v3.20.1/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/v3.20.1/build/ol.js"></script></head><body><div id="map" class="map"></div><script>//WMS的边界范围var extent=[-8380176.806709324, 4846475.643831644,-8344030.356053375, 4886005.70620772];//添加切片数据源var map = new ol.Map({layers: [new ol.layer.Tile({source: new ol.source.XYZ({//切片数据已经部署在../tomcat/webapps/ 下url: 'http://localhost:8081/PhillyBaseMap/{z}/{x}/{y}.png'})})],target: 'map',view: new ol.View({projection: 'EPSG:3857', //定义墨卡托投影zoom:4})});//重要map.getView().fit(extent, map.getSize());</script></body>
</html>
Done
这篇关于基于openlayers3调用来自geoserver的切片地图服务的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!