I am using Leaflet to work with the map. I have a WMS server: L.tileLayer.wms
.
function setWMSLayer(theme) {
if (!theme.includes("SeaChart_")) theme = "SeaChart_" + theme;
const url = `http://${FLASK_HOST}/cgi-bin/mapserv?map=/var/www/s57demo/data/map/${theme}.map`;
wmsLocal.setUrl(url);
wmsLocal.setParams({
layers: theme
});
}
const wmsLocal = L.tileLayer.wms('', {
noWrap: false
});
It uploads .map files with the configuration of my map layers. Each .map file looks something like this:
MAP
NAME SeaChart_DAY_BLACKBACK
SIZE 1000 1000
UNITS dd
EXTENT -180 -90 180 90
MAXSIZE 32768
# CONFIG "MS_OPENLAYERS_JS_URL" "http://localhost/LocalOpenLayers/OpenLayers-ms60.js"
CONFIG "MS_ERRORFILE" "/tmp/SeaChart_DAY_BLACKBACK.log"
DEBUG 5
CONFIG "ON_MISSING_DATA" "LOG"
#RESOLUTION 96
#DEFRESOLUTION 96
PROJECTION
'init=epsg:4326'
END
IMAGETYPE png
FONTSET './fonts/fontset.lst'
SYMBOLSET "./symbols/symbols-day.map"
OUTPUTFORMAT
NAME 'AGG'
DRIVER AGG/PNG
IMAGEMODE RGB
END
SHAPEPATH "../chart"
WEB
IMAGEPATH '/tmp/'
IMAGEURL '/tmp/'
METADATA
"ows_enable_request" "*"
'ows_title' 'SeaChart_DAY_BLACKBACK'
# 'ows_onlineresource' 'http://localhost/cgi-bin/mapserv.fcgi?map=/app/output/map/SeaChart_DAY_BLACKBACK.map&'
"wms_srs" "EPSG:4326 EPSG:3857 EPSG:2950 EPSG:2949 EPSG:32188 EPSG:32187 EPSG:42403 EPSG:3857 EPSG:3979"
"wfs_srs" "EPSG:4326 EPSG:3857 EPSG:2950 EPSG:2949 EPSG:32188 EPSG:32187 EPSG:42403 EPSG:3857 EPSG:3979"
"labelcache_map_edge_buffer" "10"
"wms_bbox_extended" "true"
END
END
#
# Dummy layer to create a layer group for the color mode
#
LAYER
NAME "DAY_BLACKBACK"
GROUP "default"
TYPE POINT
TRANSFORM FALSE
STATUS ON
FEATURE
POINTS 1 1 END
END
END
#INCLUDE_GSHHS_HERE
END # Map
I use MapServer to load map tiles at this path - http://${FLASK_HOST}/cgi-bin/mapserv?map=/var/www/s57demo/data/map/${theme}.map.
Leaflet uses 3857 by default.
I want to understand how I can switch the coordinate system. I understand that I can use the proj4.js and proj4leaflet.js plugins. I use them and understand how they work. But I'm not clear on how exactly I can switch my coordinate system. Additionally, I have my .map files, which also have their own projection parameters:
PROJECTION
'init=epsg:4326'
END
I have read a lot of information on the internet about this, but everywhere the information is different and unclear to me. Can someone explain the most important points so that I understand how I can change the coordinate system?
EPSG:4326
you don't need proj4.js. It's built in Leaflet. Just specify it ascrs
option when creating map withL.map
method.