CanvasMap
Getting Started Tutorials 3D Reference

Class CM2View extends CMView

Settings Group: Position

Setting Name Type Options Default Comments
Translations Position Offset Vector CMTYPE_VECTOR null,Initial:[0,0] x,y, and z values to offset the item
Rotations Rotation Vector CMTYPE_VECTOR null,Initial:[0,0] pitch, roll, and yaw values (x,y,z) values to roatate the item in degrees
Scales Scaling Vector CMTYPE_VECTOR null,Initial:[1,1] x,y, and z scaling values for the item's size

Settings Group: View2D

Setting Name Type Options Default Comments
MinZoom Min Zoom CMTYPE_FLOAT -100
MaxZoom Max Zoom CMTYPE_FLOAT 100
MaxBounds Max Bounds CMTYPE_BOUNDS null

Object Functions

Inherited From: CMView
ReturnsFunctionThrows
ZoomLevel GetZoomLevel()
SaveStyle()
RestoreStyle()
PaintImage(TheImage, PixelX, PixelY)
PaintBackground()
PaintCircle(X, Y, RadiusInPixels)
PaintRect(PixelXMin, PixelXMax, PixelYMin, PixelYMax)
PaintRoundedRect(PixelXMin, PixelXMax, PixelYMin, PixelYMax, PixelXRadius, PixelYRadius)
PaintText(XInPixels, YInPixels, Text, RadAngle)
GetRefTolerance()
GetTextWidthInPixels()
GetContext()
The GetBounds()
SetRefCenter(RefX, RefY)
Result GetRefCenter()
ZoomToBounds(NewBounds)
ZoomToMaxBounds()
ZoomIn()
ZoomOut()
ZoomTo(ZoomLevel)
ZoomToCursorCoordinate(ZoomLevel)
PixelX GetPixelXFromRefX(RefX)
PixelY GetPixelYFromRefY(RefY)
PixelCoordinate GetPixelFromRef(RefX, RefY)
PixelWidth GetPixelWidthFromRefWidth(RefWidth)
PixelHeight GetPixelHeightFromRefHeight(RefHeight)
RefWidth GetRefWidthFromPixelWidth(PixelWidth)
RefHeight GetRefHeightFromPixelHeight(PixelHeight)
RefX GetRefXFromPixelX(PixelX)
RefY GetRefYFromPixelY(PixelY)
PaintRefBounds(TheBounds)
PaintRefRect(XMin, XMax, YMin, YMax)
PaintRefArc(XMin, XMax, YMin, YMax, StartAngle, EndAngle)
PaintRefRoundedRect(XMin, XMax, YMin, YMax, RefXRadius, RefYRadius)
PaintRefCircle(X, Y, RadiusInPixels)
PaintRefText(Text, RefX, RefY, FontSize, HAlign, RadAngle)
PaintRefLine(X1, Y1, X2, Y2)
PaintRefPoly(Xs, Ys, Closed, Fill, Stroke)
PaintRefArea(TheArea, Closed, Fill, Stroke)
PaintRefRegion(TheArea, Closed, Fill, Stroke)
PaintRefImage(TheImage, RefX, RefY)
PaintRefImageScaled(TheImage, RefX, RefY, RefWidth, RefHeight)
CreateInfoWindow(ID, RefX, RefY, WindowWidth, WindowHeight, TheHTML)

Object Functions

ZoomLevel=GetZoomLevel()

Returns the current zoom level. 1 is one pixel per one map unit, doubles with each
zoom in so 2 is two pixels per map unit, 3 is 4 pixels per map unit, 4 is 16 pixels per map unit, etc.

Returns: ZoomLevel - null

SaveStyle()

Saves the current style to a stack

RestoreStyle()

Restores the style from the stack

PaintImage(TheImage, PixelX, PixelY)

Paints an image at the specified pixel location.
CanvasMap object.

Parameters:
    TheImage
    PixelX
    PixelY

PaintBackground()

Paints the background of the canvas element.

PaintCircle(X, Y, RadiusInPixels)

Paints a circle using pixel coordinate values

Parameters:
    X - horizontal pixel center of the circle
    Y - vertical pixel center of the circle
    RadiusInPixels -

PaintRect(PixelXMin, PixelXMax, PixelYMin, PixelYMax)

Paints a rectangle based on the specified bounds

Parameters:
    PixelXMin - Left side of the rectangle
    PixelXMax - Right side of the rectangle
    PixelYMin - Top of the rectangle
    PixelYMax - Bottom of the rectangle

PaintRoundedRect(PixelXMin, PixelXMax, PixelYMin, PixelYMax, PixelXRadius, PixelYRadius)

Function to paint a rounded rectangle
Adapted from: http://stackoverflow.com/questions/1255512/how-to-draw-a-rounded-rectangle-on-html-canvas

Parameters:
    PixelXMin - Left side of the rectangle
    PixelXMax - Right side of the rectangle
    PixelYMin - Top of the rectangle
    PixelYMax - Bottom of the rectangle
    PixelXRadius - Horizontal radius or both if PixelYRadius is not specified
    PixelYRadius - Vertical radius of the corners

PaintText(XInPixels, YInPixels, Text, RadAngle)

Function to paint text with the current font metrics in the context.

Parameters:
    XInPixels - left edge of the text
    YInPixels - base line for the text
    Text - the text to paint
    RadAngle - optional angle to rotate the text

GetRefTolerance()

Gets the width of the specified text in pixels based on the current font settings

GetTextWidthInPixels()

Gets the width of the specified text in pixels based on the current font settings

GetContext()

Returns the context for the CanvasMap's canvas. This is not used
often but is required do things like great gradients.

The=GetBounds()

Returns the current extent of the viewing area in reference units

Returns: The - reference bounds of the canvas map { XMin,XMax,YMin,YMax }

SetRefCenter(RefX, RefY)

Sets the center of the map to the specified coordinate. The coordinate is
at the center of the map and CM2View keeps track of the upper left-hand corner.

Parameters:
    RefX -
    RefY -

Result=GetRefCenter()

Returns the coordinate that is in the center of the view

Returns: Result - null

ZoomToBounds(NewBounds)

Zooms the view to the specified bounds. Selects a zoom level that will
contain the entire map.

Parameters:
    NewBounds -

ZoomToMaxBounds()

Zoom to the maxum bounds that have been set in the veiw

ZoomIn()

Zoom in to a higher resolution (map units are doubled relative to pixels)

ZoomOut()

Zoom in to a lower resolution (map units are halved relative to pixels)

ZoomTo(ZoomLevel)

Zoom to a specific zoom level. This can be fractional value.

Parameters:
    ZoomLevel - desired zoom level, 1 is 1:1 pixels to reference units

ZoomToCursorCoordinate(ZoomLevel)

Zoom to a specific zoom level. This can be fractional value.

Parameters:
    ZoomLevel - desired zoom level, 1 is 1:1 pixels to reference units

PixelX=GetPixelXFromRefX(RefX)

Converts a horiziontal coordinate value to a horizontal pixel value

Parameters:
    RefX horiziontal coordinate value in reference coordinates

Returns: PixelX - null

PixelY=GetPixelYFromRefY(RefY)

Converts a vertical coordinate value to a vertical pixel value

Parameters:
    RefY vertical coordinate value in reference coordinates

Returns: PixelY - null

PixelCoordinate=GetPixelFromRef(RefX, RefY)

Converts a horiziontal reference coordinate to a horizontal pixel coordinate value

Parameters:
    RefX horiziontal coordinate value in reference coordinates
    RefY vertical coordinate value in vertical coordinates

Returns: PixelCoordinate - { PixelX,PixelY }

PixelWidth=GetPixelWidthFromRefWidth(RefWidth)

Converts a horiziontal reference width to a pixel width value

Parameters:
    RefWidth horiziontal reference value

Returns: PixelWidth - null

PixelHeight=GetPixelHeightFromRefHeight(RefHeight)

Converts a vertical reference height to a pixel height

Parameters:
    RefHeight vertical height in reference units

Returns: PixelHeight - null

RefWidth=GetRefWidthFromPixelWidth(PixelWidth)

Converts a horiziontal reference width to a horizontal pixel width

Parameters:
    PixelWidth horiziontal width in pixels

Returns: RefWidth - horiziontal reference width

RefHeight=GetRefHeightFromPixelHeight(PixelHeight)

Converts a vertical reference height to a vertical pixel widthheight

Parameters:
    PixelHeight vertical height in pixels

Returns: RefHeight - vertical reference height

RefX=GetRefXFromPixelX(PixelX)

Converts a horiziontal reference value to a horizontal pixel value

Parameters:
    PixelX horiziontal coordinate value in pixels

Returns: RefX - horiziontal reference coordinate value

RefY=GetRefYFromPixelY(PixelY)

Converts a vertical reference value to a vertical pixel value

Parameters:
    PixelY vertical coordinate value in pixels

Returns: RefY - vertical reference coordinate value

PaintRefBounds(TheBounds)

Paints a rectangle based on the bounds.

Parameters:
    TheBounds

PaintRefRect(XMin, XMax, YMin, YMax)

Paints a rectangle based on the specified bounds.

Parameters:
    XMin - left edge of the rectangle
    XMax - right edge of the rectangle
    YMin - top edge of the rectangle
    YMax - bottom edge of the rectangle

PaintRefArc(XMin, XMax, YMin, YMax, StartAngle, EndAngle)

Paint an arc using reference coordinates. Can paint a circle by specifying
a StartAngle of 0 and an End angle of Math.PI*2

Parameters:
    XMin - left edge of the rectangle
    XMax - right edge of the rectangle
    YMin - top edge of the rectangle
    YMax - bottom edge of the rectangle
    StartAngle - start of the arc in radians, 0 is up
    EndAngle - end of the arc in radians

PaintRefRoundedRect(XMin, XMax, YMin, YMax, RefXRadius, RefYRadius)

Paint a rounded rectangle using reference coordinates

Parameters:
    XMin - left edge of the rectangle
    XMax - right edge of the rectangle
    YMin - top edge of the rectangle
    YMax - bottom edge of the rectangle
    RefXRadius - width/2 of the retangle containing the arc.
    RefYRadius - height/2 of the retangle containing the arc.

PaintRefCircle(X, Y, RadiusInPixels)

Function to draw a circle from a reference coordinate

Parameters:
    X
    Y
    RadiusInPixels

PaintRefText(Text, RefX, RefY, FontSize, HAlign, RadAngle)

Draw text using reference a reference coordinate. The coordinate is the left side
of the baseline for the text. If collision checking is enabled, only text that does
not collide will be painted.

Parameters:
    Text - String of text to draw
    RefX - left side of the baseline
    RefY - vertical position of the baseline
    FontSize - Height of the font in pixels, required for bounds checking to work properly
    HAlign - horizontal alignment. Left is the default, "right" and "center" also supported
    RadAngle - angle of the text. Horizontal is the default, PI/2 and -PI/2 are also supported.

PaintRefLine(X1, Y1, X2, Y2)

Function to draw a line between two reference coordinates

Parameters:
    X1 - horizontal value for first coordinate
    Y1 - vertical value for first coordinate
    X2 - horizontal value for second coordinate
    Y2 - vertical value for second coordinate

PaintRefPoly(Xs, Ys, Closed, Fill, Stroke)

Function to paint a polygon.

Parameters:
    Xs - array of horiziontal coordinate values in reference units
    Ys
    Closed - true to close the polygon (filled)
    Fill - true to fill the polygon
    Stroke - true to stroke (outline) the polygon

PaintRefArea(TheArea, Closed, Fill, Stroke)

Function to paint an area.

Parameters:
    TheArea - array of polygons
    Closed - true to close the area (filled)
    Fill - true to fill the area
    Stroke - true to stroke (outline) the area

PaintRefRegion(TheArea, Closed, Fill, Stroke)

Function to paint a region.

Parameters:
    TheArea - array of regions
    Closed - true to close the region (filled)
    Fill - true to fill the region
    Stroke - true to stroke (outline) the region

PaintRefImage(TheImage, RefX, RefY)

Function to paint an image using reference coordinates

Parameters:
    TheImage -
    RefX - Left side of the image
    RefY

PaintRefImageScaled(TheImage, RefX, RefY, RefWidth, RefHeight)

Function to draw a raster using a bounding box in reference coordinates
The second parameter may be a RefX or a Bounds object.

Parameters:
    TheImage -
    RefX - Left side of the image or a bound box
    RefY - Top of the image
    RefWidth - width of the image
    RefHeight

CreateInfoWindow(ID, RefX, RefY, WindowWidth, WindowHeight, TheHTML)

Creates an info popup window and displays the specific HTML.

Parameters:
    ID
    RefX
    RefY
    WindowWidth
    WindowHeight
    TheHTML