[mapserver-users] Run dbox on localhost
ntiamoah bernard
ntiamoah578 at yahoo.com
Thu Oct 9 11:11:41 PDT 2008
Hi guys,
I am trying to run this dbox demo on my localhost. i don't have website yet but i want to run it on my home pc. How do i do that? I am using MS4W latest version.
This is the mapfile:
#
#Start of map file, created by AmeiN! for ArcGis 02/06/2006, 2:06:22 PM
#
#
MAP
NAME 'Permits'
STATUS ON
#PROJECTION
# 'init=epsg:HTML'
#END
SIZE 650 500
EXTENT 179285.663523 4471528.000000 758248.492727 4822132.500000
UNITS meters
SHAPEPATH ''
SYMBOLSET'E:\MS4W\Apache\htdocs\symbols.sym'
FONTSET 'E:\MS4W\Apache\htdocs\fontset.txt'
CONFIG PROJ_LIB "E:\ms4w\proj\nad\"
IMAGECOLOR 255 255 255
IMAGETYPE jpeg
#
#Start of web interface definition
#
WEB
TEMPLATE 'E:\MS4W\Apache\htdocs\SampleBox\Sample.html'
IMAGEPATH 'E:\ms4w\tmp\ms_tmp\'
IMAGEURL '/ms_tmp/' #Replace 'JasperMaps' with your website name.
END #HEADER
#
# Start of querymap
#
QUERYMAP
SIZE 660 580
STATUS ON
STYLE selected
COLOR 255 0 0
STYLE hilite
End
#
#Start of legend
#
LEGEND
STATUS on
POSITION lr
KEYSIZE 18 12
#TEMPLATE 'legend.html'
LABEL
COLOR 0 0 0
TYPE TRUETYPE
FONT Arial
SIZE 9
END # END LABEL
END #LEGEND
#
# Start of scalebar
#
SCALEBAR
STATUS embed
POSITION ll
STYLE 0
INTERVALS 2
IMAGECOLOR 255 255 255
LABEL
COLOR 0 0 0
SIZE SMALL
END #LABEL
SIZE 200 3
OUTLINECOLOR 0 0 0
COLOR 0 0 0
BACKGROUNDCOLOR 255 255 255
UNITS FEET
END #SCALEBAR
#
# Start of layer definitions #
#
LAYER
NAME 'County'
TYPE POLYGON
DATA 'E:\IowaLayers\wcounty.shp'
METADATA
'wms_title' 'wcounty'
END
STATUS ON
TRANSPARENCY 100
PROJECTION
'proj=longlat'
'ellps=WGS84'
'datum=WGS84'
'no_defs'
END
MINSCALE 600
#MAXSCALE 250000
LABELITEM 'CO_NAME'
CLASS
NAME 'wcounty'
STYLE
SYMBOL 0
SIZE 6
OUTLINECOLOR 0 0 0
COLOR 0 255 127
END
LABEL
SIZE medium
COLOR 0 0 0
ANGLE 0
BUFFER 1
END
END
END
LAYER
NAME 'Highways'
TYPE LINE
DATA 'E:\IowaLayers\highway.shp'
METADATA
'wms_title' 'highway'
END
STATUS ON
TRANSPARENCY 100
PROJECTION
'proj=longlat'
'ellps=WGS84'
'datum=WGS84'
'no_defs'
END
CLASS
NAME 'highway'
STYLE
SYMBOL 0
SIZE 6
OUTLINECOLOR 241 45 105
COLOR 0 0 0
END
END
END
LAYER
NAME 'Towns'
TYPE POLYGON
DATA 'E:\IowaLayers\incorp.shp'
METADATA
'wms_title' 'incorp'
END
STATUS ON
TRANSPARENCY 100
PROJECTION
'proj=utm'
'zone=15'
'ellps=clrk66'
'datum=NAD27'
'units=m'
'no_defs'
END
CLASS
NAME 'incorp'
STYLE
SYMBOL 0
SIZE 6
OUTLINECOLOR 0 0 0
COLOR 168 100 185
END
END
END
END #End of Mapfile
Here is the template:
<html>
<head><title>My First Template (dBox)</title></head>
<!-- Walter Zorn Javascript Graphics Library -->
<script language="JavaScript" src="../dbox/src/javascript/third_party/walter_zorn/wz_jsgraphics.js"></script>
<!-- Condensed cross-browser.com x.js library -->
<script language="JavaScript" src="../dbox/src/javascript/third_party/x/x_dhtml.js"></script>
<!-- SDL Libraries -->
<script language="JavaScript" src="../dbox/src/javascript/utilities/utils.js"></script>
<script language="JavaScript" src="../dbox/src/javascript/mapserver/dbox.js"></script>
<script language="JavaScript" src="../dbox/src/javascript/mapserver/dcontainer.js"></script>
<script language="JavaScript" src="../dbox/src/javascript/mapserver/mapserv.js"></script>
<script language="javascript">
function Extent(minx, miny, maxx, maxy) {
this.minx = minx;
this.miny = miny;
this.maxx = maxx;
this.maxy = maxy;
}
config = new Object();
//config.ms_executable = "http://localhost/cgi-bin/mapserv";
config.ms_executable = "http://localhost/cgi-bin/mapserv.exe";
//config.mapfile = "/home/lime/public_html/2006/test.map";
config.mapfile = "E:\\MS4W\\mapdocs\\IowaSample.map";
config.minscale = 5000;
config.maxscale = 10000000;
//config.app_extent = new Extent(125105.727952, 4785412.819496, 788393.592828, 5488749.153129);
config.app_extent = new Extent(200000.00, 4440000.00, 750000.00, 4830000.00);
config.ref_extent = new Extent(180527.00, 4472149.00, 757628.00, 4821512.00);
config.refsizex = 243;
config.refsizey = 147;
config.reference_image = "Iowa.jpg";
config.mapsizex = 650;
config.mapsizey = 500;
// the DHTML main mapping window (note the significance of the name "main" here and the anchor image/div in the main body of the page)
var main = new dBox("main");
main.color = "red";
main.thickness = 2;
main.verbose = true;
main.useBusyMessage();
// the DHTML reference map
var reference = new dBox("reference");
reference.box = false;
var ms = new Mapserv(config.ms_executable, config.mapfile, config.app_extent.minx, config.app_extent.miny, config.app_extent.maxx, config.app_extent.maxy, config.mapsizex, config.mapsizey);
ms.queryfile = config.mapfile;
ms.minscale = config.minscale;
ms.maxscale = config.maxscale;
ms.setUnits(MAPSERV_UNITS_FEET);
// add the reference map
ms.referencemap = new Mapserv("reference", config.mapfile, config.ref_extent.minx, config.ref_extent.miny, config.ref_extent.maxx, config.ref_extent.maxy, config.refsizex, config.refsizey);
//
// drawing callback, calling ms.draw will invoke this function after building appropriate URLs
//
ms.setHandler(MAPSERV_DRAW, ms_draw);
function ms_draw() {
// update the maps (reference first)
reference.setImage(ms.referencemap.url);
main.setImage(ms.url);
// update the scalebar
// document.scalebar_miles.src = ms.mapserver + "?map=" + config.mapfile + "&mode=scalebar&mapext=0+0+" + (ms.extent[2] - ms.extent[0]) + "+" + (ms.extent[3] - ms.extent[1]) + "&mapsize=" + ms.width + "+" + ms.height;
// debug
var e = document.getElementById("debug");
if(e) e.innerHTML = " <a target=new href='" + ms.url + "'>open current image in a new window</a>";
}
//
// querying callback
//
ms.setHandler(MAPSERV_QUERY, ms_query);
function ms_query() {
querywin = window.open(ms.url, 'querywin');
querywin.focus();
}
// called from jBox/dBox when the user initiates change
reference.setHandler(DBOX_SETBOX, reference_setbox);
function reference_setbox(minx, miny, maxx, maxy) {
ms.applyReference(minx, miny); // no box dragging in the reference map
ms.draw();
}
main.setHandler(DBOX_SETBOX, main_setbox);
function main_setbox(minx, miny, maxx, maxy) {
if(ms.mode == 'map') {
if(minx != maxx && miny != maxy)
ms.applyBox(minx, miny, maxx, maxy);
else
ms.applyZoom(minx, miny);
ms.draw(); // builds draw URL and calls draw callback
} else if(ms.mode != 'map') {
ms.applyBoxQuery(minx, miny, maxx, maxy);
ms.applyPointQuery(minx, miny);
ms.query(); // builds query URL and calls query callback
}
}
// various event handlers called by jBox/dBox
main.setHandler(DBOX_MOUSEMOVE, main_mousemove);
function main_mousemove(x, y) {
var text = '';
var utmx = Number(ms.extent[0] + x*ms.cellsize);
var utmy = Number(ms.extent[3] - y*ms.cellsize);
text = " UTM Coordinates: x =" + Math.round(utmx) + " and y = " + Math.round(utmy);
var e = document.getElementById("coords");
if(e) e.innerHTML = text;
}
main.setHandler(DBOX_MOUSEEXIT, clear_coords);
main.setHandler(DBOX_MOUSEENTER, clear_coords);
function clear_coords() { var e = document.getElementById("coords"); if(e) e.innerHTML = ' '; }
main.setHandler(DBOX_MEASURE, main_measure);
function main_measure(s, t, n, a) {
var text = ' Distance: ' + Math.round(t*ms.cellsize) + " m. (" + n + " points)";
var e = document.getElementById("measure");
if(e) e.innerHTML = text;
}
main.setHandler(DBOX_AREA, main_area);
function main_area(a, d, l, n) {
var text = ' Area: ' + Math.round(a*ms.cellsize*ms.cellsize) + " sq. m. Distance: " + Math.round(l*ms.cellsize) + " m. (" + n + " points)";
var e = document.getElementById("measure");
if(e) e.innerHTML = text;
}
//
// Browser specific event handlers
//
window.onresize = function() {
main.sync();
reference.sync();
}
window.onload = function() {
main.initialize();
reference.initialize();
ms.draw();
}
</script>
<body>
<form name=mapserv>
Menu: <a href="javascript:ms.setExtent(config.app_extent.minx, config.app_extent.miny, config.app_extent.maxx, config.app_extent.maxy); ms.draw()">reset</a> | <a href="javascript:ms.draw()">refresh</a> | <a href="/~lime/2006/">live build home</a>
<p>
<table border=2>
<tr><td valign=top>
<script language="javascript">
//document.write("<img id=\"main\" src=\"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20081009/84f5474a/attachment.htm>
More information about the MapServer-users
mailing list