Constructor Summary |
|---|
|
MapCanvas
(
container
,
inputGrid
)
Create a new canvas object and initialize it.
|
Method Summary |
|---|
|
loadImage
(
newImage
,
newUseImageSize
)
Load a new static image to display for the canvas
|
|
getImageSize
(
)
Returns the dimensions of the canvas image.
|
|
getRBB
(
)
Returns the RubberBandBox object contained in the canvas.
|
|
getCanvas
(
)
Returns the Canvas surface object.
|
|
loadGrid
(
newGrid
,
newRowOffset
,
newColOffset
)
Loads a new projection grid to use for the canvas.
|
|
setClearOnClick
(
newClick
)
Chooses whether a single click on the canvas will clear the boxes.
|
|
setShowXY
(
newShow
)
Chooses whether to display the green XY box.
|
|
setShowLatLon
(
newShow
)
Chooses whether to display the red lat/lon box.
|
|
setShowSperhicalRectangle
(
newShow
)
Chooses whether to display the yellow spherical XY box.
|
|
setShowRowCol
(
newShow
)
Chooses whether to display the white row/col box.
|
|
setXYFromLatLonPolygon
(
polygon
)
Resets the XYBox values (and thus, all other values from there) to match as closely as possible the input polygon.
|
|
adjustLatLonParam
(
param
,
newValue
)
Adjusts one of the latitude/longitude parameters, and updates the boxes accordingly.
|
|
xyToLatLon
(
x
,
y
,
lat
,
lon
)
Converts an XY point to a Latitude/Longitude point
|
|
xyToRowCol
(
x
,
y
,
row
,
col
,
truncit
)
Converts an XY point to a row/col coordinate
|
|
latLonToXY
(
lat
,
lon
,
x
,
y
)
Converts a latitude/longitude point to an XY point on the map
|
|
latLonToRowCol
(
lat
,
lon
,
row
,
col
)
Converts a latitude/longitude point to a row/col coordinate
|
|
rowColToXY
(
row
,
col
,
x
,
y
)
Converts a row/col coordinate to an XY point on the map
|
|
rowColToLatLon
(
row
,
col
,
lat
,
lon
)
Converts a row/col coordinate to a lat/lon point on the map
|
|
addLatLonListener
(
newListener
)
Adds a listener function that will receive lat/lon information when a box is created.
|
|
addLatLonPolygonListener
(
newListener
)
Adds a listener function that will receive information for a lat/lon polygon when a box is created.
|
|
addRowColListener
(
newListener
)
Adds a listener function that will receive row/col information when a box is created.
|
|
addMousePosListener
(
newListener
)
Adds a listener function that will receive moust position information when the mouse is moved over the canvas
|
|
addDblClickListener
(
newListener
,
newObject
)
Adds a listener function that will receive information when a double-click event is triggered over the canvas
|
|
addSingleClickListener
(
newListener
,
newObject
)
Adds a listener function that will receive information when a single-click event is triggered over the canvas
|
|
addImgLoadListener
(
newListener
)
Adds a listener function that will receive information when an image load is completed.
|
|
getMoreMousePosInfo
(
fullpoint
)
Adds more information to a point, depending on the MapCanvas child class.
|
|
getMoreBoxInfo
(
boxinfo
)
Adds more Rubber Band Box information, depending on the MapCanvas child class
|
|
clearBox
(
)
Clears and resets the RBB boxes.
|
var mc = new MapCanvas(somediv, somegrid);
// Will create a new MapCanvas object to be contained by the
// somediv object on the page, with the projection defined in
// somegrid.
mc.loadImage(imgURL, true);
// This will load the image found at imgURL, and will cause the
// container to be stretched/shrunk to match the image size
var imgdim = mc.getImageSize();
// imgdim.width will have the width, imgdim.height will have the
// height of the image
var rbb = mc.getRBB();
var canvas = mc.getCanvas();
mc.loadGrid(newGrid, 1.1, 1.2);
// This will load the newGrid projection, and set the top left
// corner's row/col offset information.
mc.setClearOnClick(true); // single-clicks will clear the boxes
mc.setClearOnClick(false); // single-clicks don't clear the boxes
mc.setShowXY(true); // causes the green XY box to be shown
mc.setShowXY(false); // causes the green XY box to be hidden
mc.setShowLatLon(true); // causes the red lat/lon box to be shown
mc.setShowLatLon(false);// causes the red lat/lon box to be hidden
mc.setShowSphericalRectangle(true);
// causes the yellow spherical rectangle box to be shown
mc.setShowSphericalRectagle(false);
// causes the yellow spherical rectangle box to be hidden
mc.setShowRowCol(true);
// causes the white row/col box to be shown
mc.setShowRowCol(false);
// causes the white row/col box to be hidden
rbb.setXYFromLatLonPolygon("50,50,50,100,100,100,100,50,50,50");
// string form
rbb.setXYFromLatLonPolygon(50,50,50,100,100,100,100,50,50,50);
// array of integers form
rbb.setXYFromLatLonPolygon(pt1, pt2, pt3, pt4, pt1);
// array of Points formmc.adjustLatLonParam('north', 70.2);
// sets the NORTH value of the boxes to 70.2var ok = mc.xyToLatLon(100, 100, newlat, newlon);
// The latitude will be at newlat[0], the longitude will be at
// newlon[0]. ok will be true if there were no errors.
var ok = mc.xyToRowCol(100, 100, newrow, newcol, true);
// The row will be at newrow[0], the column will be at newcol[0]
// and both will be truncated to integers.
var ok = mc.latLonToXY(30.2, 51.3, newx, newy);
// newx[0] and newy[0] will contain the XY coordinate of the
// point at 30.2 north, 51.3 east.
var ok = mc.latLonToRowCol(30.2, 51.3, newrow, newcol);
// newrow[0] and newcol[0] will contain the row/col coordinate
// of the point at 30.2 north, 51.3 east.
var ok = mc.rowColToXY(8.3, 3.2, newx, newy);
// newx[0] and newy[0] will contain the XY coordinate of the
// grid row 8.3, column 3.2 on the map.
var ok = mc.rowColToLatLon(8.3, 3.2, newlat, newlon);
// newlat[0] and newlon[0] will contain the lat/lon coordinate
// of grid row 8.3, column 3.2 on the map.
mc.addLatLonListener(newLLfunc);
// adds newLLfunc to the listener list for the class
mc.addLatLonPolygonListener(newLLPfunc);
// adds newLLPfunc to the listener list for the class
mc.addRowColListener(newRCfunc);
// adds newRCfunc to the listener list for the class
mc.addMousePosListener(newMousefunc);
// adds newLLfunc to the listener list for the class
mc.addDblClickListener(newDCfunc, this);
// adds newDCfunc to the listener list for the class, and will
// return "this" with the event
mc.addSingleClickListener(newSCfunc, this);
// adds newSCfunc to the listener list for the class, and will
// return "this" with the event
mc.addImgLoadListener(newILfunc);
// adds newILfun to the listener list
this.getMoreMousePosInfo(thispoint);
// Will add more info to thispoint
parent.getMoreBoxInfo(thisbox);
// Will add more info to thisbox
mc.clearBox(); // Resets the rubberband boxes