Created
November 20, 2012 12:37
-
-
Save ponkore/4117681 to your computer and use it in GitHub Desktop.
mapserver の mapscript サンプル。近畿、中国地方ら辺で緯度経度を指定。OpenLayers からの呼び出し方がわからない。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shp2img -m /Library/WebServer/CGI-Executables/mapserver/example06.map -o ~/out.png -s 1920 1080 | |
MAP | |
DEBUG 5 | |
CONFIG "MS_ERRORFILE" "tmp/ms_error.txt" | |
EXTENT 129.7 32.9 138.0 38 | |
WEB | |
METADATA | |
"wms_title" "WMS Server" | |
"wms_onlineresource" "http://localhost/cgi-bin/mapserv?map=/Library/WebServer/CGI-Executables/mapserver/example06.map&" | |
# "wms_srs" "EPSG:4326 EPSG:900913" | |
"wms_srs" "EPSG:4326 EPSG:3857" | |
# "ows_enable_request" "*" | |
"wms_enable_request" "*" | |
END | |
IMAGEPATH "tmp/" | |
IMAGEURL "http://localhost/cgi-bin/mapserver/tmp/" | |
END | |
FONTSET "./fonts/fonts.list" | |
PROJECTION | |
"init=epsg:4326" # WGS84 | |
END | |
LAYER | |
NAME "admarea" | |
METADATA | |
"DESCRIPTION" "admarea" | |
"wms_title" "admarea" | |
"wms_srs" "EPSG:4326 EPSG:54004" | |
END | |
EXTENT 129.7 32.9 138.0 38 | |
CONNECTIONTYPE POSTGIS | |
CONNECTION "user=postgres password='' dbname=postgis_db host=localhost" | |
DATA "geom FROM admarea" # ' USING UNIQUE gid' select文 | |
TYPE POLYGON | |
STATUS ON | |
CLASS | |
STYLE | |
OUTLINECOLOR 255 215 0 | |
COLOR 240 230 140 | |
# COLOR 64 64 64 | |
# WIDTH 2.0 | |
END | |
END | |
END | |
# LAYER | |
# NAME "label" | |
# DATA osm_polygon | |
# STATUS ON # DEFAULTからONに変更 | |
# TYPE POLYGON | |
# | |
# LABELITEM "NAME" | |
# | |
# CLASS | |
# STYLE | |
# OUTLINECOLOR 255 215 0 | |
# COLOR 240 230 140 | |
# END | |
# | |
# LABEL | |
# TYPE TRUETYPE | |
# # FONT mincho | |
# FONT gothic | |
# #ENCODING SJIS | |
# ENCODING CP932 | |
# | |
# SIZE 8 | |
# COLOR 255 0 0 | |
# END | |
# END | |
# END | |
# | |
# LAYER | |
# NAME "line" | |
# DATA osm_line_road | |
# STATUS ON | |
# TYPE LINE | |
# | |
# CLASS | |
# STYLE | |
# COLOR 64 64 64 | |
# WIDTH 2.0 | |
# END | |
# END | |
# END | |
END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- 今のところ思うように動いていない。 --> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<link rel="stylesheet" href="theme/default/style.css" type="text/css"> | |
<link rel="stylesheet" href="style.css" type="text/css"> | |
<title>例5)OpenLayers + WMS</title> | |
<script src="lib/OpenLayers.js"></script> | |
<script type="text/javascript"> | |
var map; | |
var urls = [ | |
"http://a.tile.openstreetmap.org/${z}/${x}/${y}.png", | |
"http://b.tile.openstreetmap.org/${z}/${x}/${y}.png", | |
"http://c.tile.openstreetmap.org/${z}/${x}/${y}.png" | |
]; | |
function init(){ | |
var controls = [ | |
new OpenLayers.Control.MousePosition(), | |
new OpenLayers.Control.KeyboardDefaults(), | |
new OpenLayers.Control.Navigation(), | |
new OpenLayers.Control.LayerSwitcher(), | |
new OpenLayers.Control.Scale(), | |
new OpenLayers.Control.PanZoomBar() | |
]; | |
map = new OpenLayers.Map( 'map', { | |
controls : controls, | |
maxScale : 1000, | |
minScale : 500000 | |
}); | |
var layerAdmArea = new OpenLayers.Layer.WMS( "MapServer WMS - AdmArea", | |
"/cgi-bin/mapserv?map=mapserver/example06.map&SERVICE=WMS&VERSION=1.1.1&", /* &SRS=EPSG:54004 */ | |
{ | |
map : "mapserver/example06.map", | |
layers: "admarea", | |
format: "image/png", | |
transparent: true | |
}, { | |
isBaseLayer : false, | |
visibility : true, | |
opacity: 0.5 | |
} ); | |
var layerOSM = new OpenLayers.Layer.XYZ("OSM (with buffer)", urls, { | |
transitionEffect: "resize", | |
buffer: 2, | |
sphericalMercator: true, | |
opacity: 0.5, | |
isBaseLayer: true | |
}); | |
map.addLayer(layerOSM); | |
map.addLayer(layerAdmArea); | |
var lon = 135.49554515839566; | |
var lat = 34.70271324154254; | |
var zoom = 15; | |
var lonLat = new OpenLayers.LonLat(lon, lat) | |
.transform( | |
new OpenLayers.Projection("EPSG:4326"), | |
new OpenLayers.Projection("EPSG:3857") /* new OpenLayers.Projection("EPSG:900913") */ | |
); | |
map.setCenter(lonLat, zoom); | |
} | |
</script> | |
</head> | |
<body onload="init()"> | |
<h1>例5)OpenLayers + WMS</h1> | |
<span>シンプルなOpenLayersからのMapServer WMS利用</span> | |
<div id="map" class="smallmap"></div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://localhost/cgi-bin/mapserv?map=mapserver/example06.map&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&LAYERS=admarea&FORMAT=image/png&SRS=EPSG:4326&WIDTH=600&HEIGHT=400 | |
# REQUEST=GetCapability | |
http://localhost/cgi-bin/mapserv?map=mapserver/example06.map&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&LAYERS=admarea&FORMAT=png&SRS=EPSG:4326&WIDTH=600&HEIGHT=400&BBOX=135.5,35.5,136.5,36.5 | |
#### max size !!! | |
## kml ## | |
http://localhost/cgi-bin/mapserv?map=mapserver/example06.map&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&LAYERS=admarea&FORMAT=kml&SRS=EPSG:4326&WIDTH=1200&HEIGHT=800&BBOX=129.7,32.9,138.0,38 | |
## png ## | |
http://localhost/cgi-bin/mapserv?map=mapserver/example06.map&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&LAYERS=admarea&FORMAT=png&SRS=EPSG:4326&WIDTH=1200&HEIGHT=800&BBOX=129.7,32.9,138.0,38 | |
http://localhost/cgi-bin/mapserv?map=mapserver/example06.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment