2017-05-01 3 views
0

Ich verwende Openlayer3, um eine Rasterebene über MapServer WMS hinzuzufügen. Beim Laden der Seite ändert sich der CRS-Wert in der WMS-URL zu 3857.Wie CRS in Openlayer 3 WMS (Kartenserver) ändern?

Arbeits Mapserver URL

http://localhost/cgi-bin/mapserv.exe?map=D: \ mapserver \ actualimage.map & SERVICE = WMS & VERSION = 1.3.0 & REQUEST = GetMap & LAYERS = Gujarat & STYLES = & CRS = EPSG: 32643 & BBOX = 361.600,51891405135 , 2404154.8014285564,366487.01241288986,2409041.294927395 & WIDTH = 800 & HÖHE = 500 & FORMAT = image/png

Die Openlayers anfordert die URL unten

http://localhost/cgi-bin/mapserv.exe?map=D:%5Cmapserver%5Cactualimage.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Gujarat&CRS=EPSG%3A3857&BBOX=360378.8955393417%2C2402933.1780538466%2C367708.6357875995%2C2410262.918302105&WIDTH=1&HEIGHT=1&STYLES=

als

dekodierten http://localhost/cgi-bin/mapserv.exe?map=D: \ mapserver \ actualimage.map & SERVICE = WMS & VERSION 1.3.0 = & REQUEST = GetMap & FORMAT = image/PNG & TRANSPARENT = true & LAYERS = Gujarat & CRS = EPSG: 3857 & BBOX = 360378.8955393417,2402933.1780538466,367708.6357875995,2410262.918302105 & WIDTH = 1 & HÖHE = 1 & STYLES =

Unten ist die Openlayers Code

var layers = [ 
      new ol.layer.Image({ 
       extent: [361600.51891405135,2404154.8014285564,366487.01241288986,2409041.294927395], 
       source: new ol.source.ImageWMS({ 
        url: encodeURI('http://localhost/cgi-bin/mapserv.exe?map=D:\\mapserver\\actualimage.map'), 
        params: { 
         'LAYERS': 'Gujarat', 
         'CRS': 'EPSG:32643', 
         'BBOX': '361600.51891405135,2404154.8014285564,366487.01241288986,2409041.294927395', 
         'WIDTH': '800', 
         'HEIGHT': '500', 
         'FORMAT': 'image/png' 
        }, 
        serverType: 'mapserver', 
        projection: ol.proj.get('EPSG:32643'), 
       }) 
      }) 
     ]; 
     var map = new ol.Map({ 
      layers: layers, 
      target: 'map', 
      view: new ol.View({ 
       center: [361600.51891405135, 2404154.8014285564], 
       zoom: 1 
      }) 
     }); 

Antwort

1

Sofern Sie 'EPSG:32643' als Projektion registriert haben (z durch Verwendung und Konfiguration von proj4js), ol.proj.get('EPSG:32643') wird null zurückgeben. Wenn Sie die Projektion ordnungsgemäß registriert haben, projiziert OpenLayers Ihre WMS-Schicht erneut auf die Ansichtsprojektion ('EPSG:3857'), die Sie möglicherweise nicht benötigen.

Um ohne Raster Reprojektion zu gehen, projection: 'EPSG:32643' on both your ol.source.ImageWMS and your ol.View . Also note that the coordinates of the view's Zentrum need to be in ``'EPSG:32643' in diesem Fall konfigurieren.