博客
关于我
WebGIS(PostgreSQL+GeoServer+Open…
阅读量:191 次
发布时间:2019-02-28

本文共 1348 字,大约阅读时间需要 4 分钟。

数据在GeoServer中配置好之后,可以编写OpenLayers的WMS请求服务。完成配置后,可以通过浏览器查看地图。以下是实现地理数据在OpenLayers上显示的HTML代码和实现方法。

开启地理数据显示之旅

在OpenLayers上显示地理数据需要以下几个步骤:首先,确保GeoServer已正确配置;其次,编写OpenLayers的WMS请求服务;最后,通过浏览器查看地图。

OpenLayers WMS请求服务配置

编写OpenLayers的WMS请求服务时,可以遵循以下步骤:

#map {  width: 800px;  height: 434px;  border: 1px solid black;}
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;map = new OpenLayers.Map('map', {  controls: [],  projection: 'EPSG:4326',  units: 'degrees'});
// 设置地理坐标范围var bounds = new OpenLayers.Bounds(  70.56262702941892,  16.39964122772222,  137.82589988708528,  55.32298831939698);// 添加WMS图层var tiled = new OpenLayers.Layer.WMS(  "topp:china",  "http://localhost:8080/geoserver/wms",  {    srs: 'EPSG:4326',    width: '800',    height: '434',    styles: '',    layers: 'topp:china',    format: 'image/png',    tiled: 'true',    tilesOrigin: "70.56262702941892,16.39964122772222"  });
map.addLayer(tiled);map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);map.addControl(new OpenLayers.Control.PanZoomBar());map.addControl(new OpenLayers.Control.LayerSwitcher());

实现说明

  • GeoServer配置:确保GeoServer已正确配置,并且能够提供所需的WMS服务。

  • OpenLayers初始化:使用OpenLayers初始化地图,并设置合适的投影和坐标单位。

  • WMS图层添加:创建一个WMS图层,并配置其参数,如图层名称、服务URL、坐标范围等。

  • 地图显示:将创建好的图层添加到地图上,并设置地图的中心位置和缩放级别。

  • 控制器添加:添加必要的控制器,如平移缩放条和图层切换器,以便更好地操作地图。

  • 通过以上步骤,可以实现地理数据在OpenLayers上准确显示。如果需要更详细的配置或有其他需求,建议参考OpenLayers的官方文档或相关技术资料。

    转载地址:http://qmpj.baihongyu.com/

    你可能感兴趣的文章
    NN&DL4.3 Getting your matrix dimensions right
    查看>>
    NN&DL4.8 What does this have to do with the brain?
    查看>>
    No 'Access-Control-Allow-Origin' header is present on the requested resource.
    查看>>
    No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
    查看>>
    No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
    查看>>
    No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
    查看>>
    No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
    查看>>
    No module named cv2
    查看>>
    No module named tensorboard.main在安装tensorboardX的时候遇到的问题
    查看>>
    No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
    查看>>
    No new migrations found. Your system is up-to-date.
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
    查看>>
    NO.23 ZenTaoPHP目录结构
    查看>>
    NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
    查看>>
    Node JS: < 一> 初识Node JS
    查看>>
    Node-RED中使用JSON数据建立web网站
    查看>>
    Node-RED中使用node-red-browser-utils节点实现选择Windows操作系统中的文件并实现图片预览
    查看>>
    Node-RED中使用Notification元件显示警告讯息框(温度过高提示)
    查看>>