CanvasMap
Getting Started Tutorials 3D Reference

Class CMMainContainer extends CMPanel

CMMainContainer Class

Main class to contain the other elements and objects that make up a CMMainContainer.

The elements for a CMMainContainer are held in an array,

Settings Group: MainContainer

Setting Name Type Options Default Comments
Scene3D 3D Scene CMTYPE_BOOLEAN false true to create a 3D scene instead of a 2D scene
AllowMouseEvents Allow Mouse Events CMTYPE_BOOLEAN true false to create a static map
MobileSupported Mobile Supported CMTYPE_BOOLEAN false true to enable jestures on phones and pads
Resize Resize CMTYPE_BOOLEAN false true to have the map automatically resize when the window is resized
ImageFolder Image Folder CMTYPE_STRING ../Images/ path to the folder with the images for the main container (e.g. tool icons)
MapNumber MapNumber CMTYPE_INTEGER 0 true to have the map automatically resize when the window is resized
MainContainerElementID MainContainer Element ID CMTYPE_STRING CM_MapContainer
MainContainerClassName MainContainer Class Name CMTYPE_STRING CM_MapContainer
CanvasContainerID Canvas Container ID CMTYPE_STRING CM_CanvasContainer
CanvasContainerClassName Canvas Container Class Name CMTYPE_STRING CM_CanvasContainer
CanvasContainerWithoutPanelsClassName Canvas Container Without Panels Class Name CMTYPE_STRING CM_CanvasContainerWithoutPanels
CanvasID Canvas ID CMTYPE_STRING CM_Canvas
CanvasClassName Canvas Class Name CMTYPE_STRING CM_Canvas
PanelFooterID Footer Panel ID CMTYPE_STRING
PanelToolID Tool Panel ID CMTYPE_STRING
PanelButtonsID Button Panel ID CMTYPE_STRING
ControlsLocation ControlsLocation CMTYPE_ENUMERATED "None", "MainContainer", "CanvasContainer" MainContainer
EditorContainerID EditorContainerID CMTYPE_STRING CM_Editor tab container for the editor

Static Functions

ReturnsFunctionThrows
SetPopupWindow(NewPopupWindow)
HidePopupWindows()

Object Functions

Inherited From: CMPanel
ReturnsFunctionThrows
SetCoordinateUnits(CoordinateUnits)
SimpleMap()
Initialize(TheView)
TheScene GetScene()
TheView GetView()
TheToolPanel GetToolPanel()
footer GetPanelFooter()
SetProjector(TheProjector)
TheProjector GetProjector()
SelectTool(ViewToolDef)
AddLayer(NewLayer)
AddBackground(NewLayer)
AddBackgrounds(NewLayer)
SetSelectedBackgroundIndex()
ZoomIn()
ZoomOut()
ZoomToMax()
ZoomToBounds(TheBounds)
ZoomTo(ZoomLevel)
SetRefCenter(RefX, RefY)
StartMap(ResizeFlag)
Resize()

Static Functions

SetPopupWindow(NewPopupWindow)

Sets the current popup window and hides any existing windows

Parameters:
    NewPopupWindow - the DOM element with the visible window

HidePopupWindows()

Sets the current popup window and hides any existing windows

Object Functions

SetCoordinateUnits(CoordinateUnits)

Changes the coordinate units
Deprecated, use SetSetting("MainContainer","CoordinateUnits",CoordinateUnits) instead

Parameters:
    CoordinateUnits - one of the coordinate definitions:

SimpleMap()

Helper function to turn off all the elements except the main map

Initialize(TheView)

This is the function to call to initialize the CMMainContainer. It sets up the member variables,
links the objects together, and sets up the event handlers.

Parameters:
    TheView - Optional 2D or 3D view. If undefined, a 2D view is created, if true, a 3D view is created.

TheScene=GetScene()

Get the scene object that contains the layers for the map

Returns: TheScene - the current scene for this map.

TheView=GetView()

Get the specified view or the first view in the first scene for the CMMainContainer.
functions.

Returns: TheView - the first view for the first scene.

TheToolPanel=GetToolPanel()

Get the tool panel that is associated with this main container, if any
functions.

Returns: TheToolPanel - or null for none

footer=GetPanelFooter()

Get the footer panel that is associated with this main container, if any
functions.

Returns: footer - panel or null for none

SetProjector(TheProjector)

Set the projector for coordinate conversion

Parameters:
    TheProjector - the projector to use to project coordinates

TheProjector=GetProjector()

Gets the current projector for coordinate conversion

Returns: TheProjector - null

SelectTool(ViewToolDef)

Set the current tool selected for interacting with the map

Parameters:
    ViewToolDef - sets the current tool (e.g. CMToolHandler.TOOL_INFO)

AddLayer(NewLayer)

Add a layer to the map. The layer will be on top of other layers

Parameters:
    NewLayer - CMLayer object to add to the map

AddBackground(NewLayer)

Add background to the list

Parameters:
    NewLayer - CMLayer object to add to the backgrounds. Only one background will

AddBackgrounds(NewLayer)

Adds a current set of open source backgrounds to the background list

Parameters:
    NewLayer - CMLayer object to add to the backgrounds. Only one background will

SetSelectedBackgroundIndex()

ZoomIn()

called to zoom the map in by 2x

ZoomOut()

called to zoom the map out by 2x

ZoomToMax()

Zooms the map to the maximum specified value

ZoomToBounds(TheBounds)

called to zoom the map to a specific area of the scene.

Parameters:
    TheBounds - boundary object { XMin,XMax,YMin,YMax}

ZoomTo(ZoomLevel)

Zooms to the specified zoom level

Parameters:
    ZoomLevel - level to zoom to, 1=1 pixel per map unit, 2=pixels per map unit, etc.)

SetRefCenter(RefX, RefY)

Centers the map at RefX,RefY in the first view

Parameters:
    RefX - Longitude or easting for the center of the map
    RefY - Latitude or northing for the center of the map

StartMap(ResizeFlag)

jjg - deprecated
StartMap() should be called after all the layers are added to start up the map and
fill out the layer list. Layers can be added and removed later as well but the user
may see them being added.

Parameters:
    ResizeFlag - If true, the map will be resized right away. Otherwise, the size

Resize()

Called to resize the map when the window size changes.
The only reason this is needed is because
we have to use JavaScript to resize the Canvas HTML element, CSS does not work.