I want to display a shapefile in OpenLayers using MapServer 7.6. It is shown properly in the browser using the mapfile's link.
But when I try to display it in OpenLayers, the geometry is completely ruined.
I get no error messages.
What is the cause of this and how could I solve this?
Here is my code:
const map=new ol.Map({
view: new ol.View({
center: [2294319.8093533223, 5942407.910713993],
zoom: 1
}),
target: "js-map"
})
var wmsSource = new ol.source.ImageWMS({
url: 'http://localhost/cgi-bin/mapserv.exe?MAP=/ms4w/apps/GEO/test.map',
params: {'LAYERS': 'world'},
serverType: 'mapserver',
crossOrigin: 'anonymous'
});
var wmsLayer = new ol.layer.Image({
source: wmsSource,
title: "world"
});
const overlayGroup=new ol.layer.Group({
title: "Overlays",
fold: 'open',
layers: [wmsLayer]
})
map.addLayer(overlayGroup);
var layerSwitcher=new ol.control.LayerSwitcher({
groupSelectStyle: 'group'
});
map.addControl(layerSwitcher);
And the mapfile:
MAP
EXTENT -180 -90 180 90
IMAGETYPE "png"
NAME "world"
SIZE 1381 1025
STATUS ON
UNITS METERS
OUTPUTFORMAT
NAME "png"
MIMETYPE "image/png"
DRIVER "AGG/PNG"
EXTENSION "png"
IMAGEMODE RGB
TRANSPARENT FALSE
END # OUTPUTFORMAT
SYMBOL
NAME "symbol1"
TYPE ELLIPSE
FILLED TRUE
POINTS
1 1
END
END
PROJECTION
"init=epsg:4326"
END # PROJECTION
LEGEND
KEYSIZE 20 10
KEYSPACING 5 5
LABEL
SIZE 10
OFFSET 0 0
SHADOWSIZE 1 1
END # LABEL
STATUS OFF
END # LEGEND
QUERYMAP
SIZE -1 -1
STATUS OFF
STYLE HILITE
END # QUERYMAP
SCALEBAR
INTERVALS 4
LABEL
SIZE 10
OFFSET 0 0
SHADOWSIZE 1 1
END # LABEL
SIZE 200 3
STATUS OFF
UNITS MILES
END # SCALEBAR
WEB
METADATA
"wms_srs" "EPSG:4326 EPSG:3857"
"wms_onlineresource" "http://localhost/cgi-bin/mapserv.exe?MAP=/ms4w/apps/GEO/test.map"
"wms_enable_request" "*"
"mapmanager_version" "1.1.0.0"
"ows_enable_request" "*"
"wms_feature_info_mime_type" "text/html"
"wms_encoding" "UTF-8"
"wms_title" "world"
END # METADATA
END # WEB
LAYER
DATA "E:/VECTOR/world_countries.shp"
METADATA
"wms_include_items" "all"
"wms_title" "world"
END # METADATA
NAME "world"
PROJECTION
"init=EPSG:4326"
END # PROJECTION
STATUS DEFAULT
TILEITEM "location"
TYPE POLYGON
UNITS METERS
CLASS
NAME "world"
STYLE
COLOR 58 132 59
OUTLINECOLOR 30 30 30
END # STYLE
END # CLASS
END # LAYER
END # MAP