基于openlayers3调用来自geoserver的wms服务
基于openlayers3调用来自geoserver的wms服务
基于openlayers3调用来自geoserver的wms服务
<!doctype html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"><meta name="apple-mobile-web-app-capable" content="yes"><link rel="stylesheet" href=".20.1/css/ol.css" type="text/css"><style>.map {height: 400px;width: 100%;}</style><script src=".20.1/build/ol.js" type="text/javascript"></script><title>OpenLayers 3 example</title></head><body onload="init()"><h2>My Map</h2><div id="map" class="map"></div><script type="text/javascript">//基于openlayers3function init(){//WMS的边界范围var extent=[-8380176.806709324, 4846475.643831644,-8344030.356053375, 4886005.70620772];//wms作底图var tiled = [new ol.layer.Tile({source: new ol.source.TileWMS({url: 'http://localhost:8080/geoserver/webgis/wms',//自己的wms地址,可在geoserver中以openlayerView查看params: { 'LAYERS': 'webgis:NeighborhoodMap','TILED':false },serverType:'geoserver'})})];//定义投影 EPSG:3857:墨卡托var projection = new ol.proj.Projection({code: 'EPSG:3857',units: 'm',axisOrientation: 'neu',global: true});//定义地图对象var map = new ol.Map({layers: tiled,target: 'map',view: new ol.View({projection: 'EPSG:3857',zoom:4}),controls: ol.control.defaults({ attributionOptions: { collapsible: false } })});//非常重要 very importantmap.getView().fit(extent, map.getSize());}</script></body>
</html>
Done
最新文章
- 物权法全文内容有哪些呢
- 【CocosBuilder 开发系列之一】cocos2dx使用CocosBuilder(编辑器)完成基础骨骼动画
- IIS网站安全设置
- Azure App object和Service Principal
- HTK语音识别工具包的安装和编译
- CA6140车床拨叉工艺及铣30X80面夹具设计
- Ext 2 概述
- C语言中的void和void指针
- ADFS 概念与基本开发介绍
- CLion 插件
- Idea 精准到类的打包方式:Artifacts 打包
- 常用的Linux终端命令盘点
- vc++ C函数atoi和itoa的用法总结(转载)
- extern用法详解
- shiro的基本认识
- 高斯函数详解
- cs,ds,ss,es?即cs,ds,ss,es的区别