Код: Выделить всё
MAP
NAME "WMS"
STATUS ON
IMAGETYPE PNG
EXTENT 37.6825 44.3103 40.6413 55.5705
SIZE 800 2048
UNITS DD
IMAGECOLOR 255 255 255
FONTSET "./fonts/fonts.list"
WEB
TEMPLATE './templates/template.html'
IMAGEPATH '/ms4w/tmp/ms_tmp/'
IMAGEURL '/ms_tmp/'
METADATA
wms_enable_request "*"
wms_title "GIS-LAB Demo"
wms_abstract "This is the WMS demo from GIS-Lab"
wms_onlineresource "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/example/wms - mezhuzl.map&"
wms_srs "EPSG:4326"
wms_getfeatureinfo "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/example/wms - mezhuzl.map&"
wms_featureinfoformat "text/plain"
END
END
PROJECTION
"proj=latlong"
"ellps=WGS84"
"datum=WGS84"
END
LAYER
NAME veget
CONNECTIONTYPE postgis
CONNECTION "user=postgres password=123 dbname=postgis host=localhost"
DATA "the_geom from roadmezhuzl"
STATUS ON
TYPE LINE
PROJECTION
"proj=latlong"
"ellps=WGS84"
"datum=WGS84"
END
CLASS
NAME "Ось дороги"
STYLE
COLOR 5 115 253
OUTLINECOLOR 32 32 32
END
END
METADATA
wms_title "Countries 1"
wms_abstract "Countries 1 test"
wms_srs "EPSG:4326"
wms_include_items "all"
END
END # Конец определения слоя
END # Конец определения карты
Подключаю через OpenLayers
Код: Выделить всё
var map, select;
var lat=60;
var lon=80;
var zoom = 5;
function init(){
var OSM_map = new OpenLayers.Layer.OSM("OpenStreetMap");
var gmap = new OpenLayers.Layer.Google("Google Streets", {visibility: false});
var Y_map = new OpenLayers.Layer.Yandex("Yndex",{sphericalMercator: true, visibility: false});
var wms = new OpenLayers.Layer.WMS("Layer", "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/example/wms - mezhuzl.map&",
{transparent: 'true', layers: 'veget', format: 'png'},
{isBaseLayer:false});
var mapoptions = {
projection: "EPSG:900913",
sphericalMercator: true,
units: "m",
numZoomLevels:18,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-128 * 156543.0339, -128 * 156543.0339, 128 * 156543.0339, 128 * 156543.0339)
};
map = new OpenLayers.Map("map", mapoptions);
map.addLayers([OSM_map, gmap, Y_map, wms]);
var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
map.setCenter (lonLat, zoom);
map.addControl(new OpenLayers.Control.LayerSwitcher());
}