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,

Copyright (C) 2020, Humboldt State University, Jim Graham

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General
Public License as published by the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see
.

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
Resize Resize CMTYPE_BOOLEAN false true to have the map automatically resize when the window is resized
ImageFolder Image Folder CMTYPE_STRING ../Images/ (jjg no longer used) 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 Controls Location CMTYPE_ENUMERATED "None", "MainContainer", "CanvasContainer" MainContainer specify whether to have the controls in a panel in the main container or on top of the map
IncludeLayerList Include Layer List CMTYPE_BOOLEAN true true to add the panel with the list of foreground layers
IncludeBackgroundPanel IncludeBackgroundPanel CMTYPE_BOOLEAN true true to add the panel with the list of background layrs
IncludeSearchPanel IncludeSearchPanel CMTYPE_BOOLEAN true true to add the search options
IncludeDevEditor Include Dev Editor CMTYPE_BOOLEAN false true to add the development editor panels

Static Functions

ReturnsFunctionThrows
SetPopupWindow(NewPopupWindow)
AddPopupWindow(NewPopupWindow)
HidePopupWindows()
AddGlobalEventListener()
RemoveGlobalEventListener()

Object Functions

Inherited From: CMPanel
ReturnsFunctionThrows
SetCoordinateUnits(CoordinateUnits)
SimpleMap()
CanvasFullScreen()
Initialize(TheView)
TheScene GetScene()
GetGeo()
GetLayerForegrounds()
GetLayerBackgrounds()
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

AddPopupWindow(NewPopupWindow)

Adds a new popup window. Existing popup windows will remain open

Parameters:
    NewPopupWindow - the DOM element with the visible window

HidePopupWindows()

Sets the current popup window and hides any existing windows

AddGlobalEventListener()


RemoveGlobalEventListener()

Investigating handling more complex mouse movements

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

CanvasFullScreen()

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.

GetGeo()

Convenience function to the first CMGeo object

GetLayerForegrounds()

Convenience function to return the list of foreground layers

GetLayerBackgrounds()

Convenience function to return the list of background layers

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.