简体   繁体   English

在ol3中通过Map Sever渲染错误地提供WMS图层

[英]WMS Layer provide by Map Sever rendering incorrectly in ol3

I have created a map using OpenLayers3 which contains two layers. 我使用OpenLayers3创建了一个包含两层的地图。 First layer is Open Street Map Layer and the second one is WMS layer provided by the Map Server. 第一层是开放街道地图层,第二层是地图服务器提供的WMS层。

Problem- When i'm rendering first layer it is rendering properly no issue. 问题 -当我渲染第一层时,它正确渲染没有问题。 but when i'm rendering the second layer(provide by map server) it renders incorrectly means it does not fit to its container and it is out of sync with the first layer in terms of location. 但是当我渲染第二层(由地图服务器提供)时,渲染错误意味着它不适合其容器,并且就位置而言与第一层不同步。 See this snapshot of the maps for more clarification. 有关详细说明,请参阅地图快照 In the snapshot top layer is wms layer provide by map server. 在快照顶层是由地图服务器提供的wms层。

在此输入图像描述

Also when i'm zooming or moving the map then both layers work correctly but after a delay of few seconds the second layer(wms layer from map server) again switches back to its initial position(Position that is shown in above attached snapshot). 此外,当我缩放或移动地图时,两个图层都能正常工作,但是在几秒钟的延迟之后,第二层(来自地图服务器的wms图层)再次切换回其初始位置(位于上面附加的快照中的位置)。

This is the code that i'm using to consume wms service. 这是我用来使用wms服务的代码。

var layer = new ol.layer.Image({
    source: new ol.source.ImageWMS({
          url: 'http://localhost:19090/rasters/world/wms',
          params: {
               'LAYERS': 'world',
               'mode': 'map',
          },
          serverType: 'mapserver'
     })
});

This is my map file. 是我的地图文件。

MAP
  NAME   "world"
  CONFIG "MS_ERRORFILE" "/home/neelesh/Projects/georbis/data/logs/mapservice_errors.log"
  CONFIG "PROJ_LIB" "/home/neelesh/Projects/georbis/deps/proj.4-master/share/proj"
  CONFIG "ON_MISSING_DATA" "LOG"
  DEBUG 5
  EXTENT -180.000 -90.000 180.000 90.000
  SHAPEPATH "/home/neelesh/Projects/georbis/data/service_data/data/wms"
  IMAGECOLOR 255 255 255
  SIZE 1350 675

  WEB
    METADATA
      "wms_title" "Georbis WMS Server"
      "wms_author" "VizExperts"
      "wms_onlineresource" "http://192.168.1.36:19090/rasters/world/wms?"
      "wms_enable_request" "*"
      "wms_srs" "EPSG:4326 EPSG:3857"
      "wms_feature_info_mime_type" "text/html"
      "wms_format" "image/jpg"
    END
  END

  PROJECTION
    "init=epsg:4326"
  END

  LAYER
    NAME world
    TYPE RASTER
    DATA "world.tif"
    METADATA
      "wms_title" "BlueWorld Map"
      "wms_srs" "epsg:4326"
      "wms_server_version" "1.1.1"
    END
    PROJECTION
      "init=epsg:4326"
    END
  END
END

I tried ol.view.fit method to fit the layer to its container but the value of layer.getExtent() for the layer is undefined. 我尝试使用ol.view.fit方法将图层调整到其容器,但图层的layer.getExtent()值未定义。

Pleas help me to find out what is wrong. 请求帮助我找出问题所在。 is there any problem with wms request format or the map file? wms请求格式或地图文件有什么问题吗?

It's because you configured your MapServer to support only EPSG 4326. It should support EPSG 3857 (the OSM tiles). 这是因为您将MapServer配置为仅支持EPSG 4326.它应该支持EPSG 3857(OSM磁贴)。 You should change "wms_srs" "epsg:4326" to "wms_srs" "EPSG:4326 EPSG:3857" (see the official WMS server doc ). 您应该将"wms_srs" "epsg:4326"更改为"wms_srs" "EPSG:4326 EPSG:3857" (请参阅官方WMS服务器文档 )。 You can confirm it works doing a GetCapabilities request . 您可以确认它可以执行GetCapabilities请求

When you use GeoServer, by default, it supports all projections for WMS (so it works because your WMS images are requested with EPSG 3857) 当您使用GeoServer时,默认情况下,它支持WMS的所有投影(因此它可以工作,因为您的WMS图像是通过EPSG 3857请求的)

You should be aware that now you can also do raster reprojection on client in OpenLayers. 您应该知道,现在您也可以在OpenLayers中对客户端进行光栅重投影。 For some demos, go to http://openlayers.org/en/v3.11.0/examples/ and search with keyword "reprojection" 对于某些演示,请访问http://openlayers.org/en/v3.11.0/examples/并使用关键字“reprojection”进行搜索

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM