GeometryControls

GeometryControls is a supervisor class used by geometry digiziting controls, like those in Google's MyMaps.
Work is delegated from instances of actual controls (@see MarkerControl, etc) to convenient methods that all control's require,
like constructing InfoWindows, applying styles, saving data, and managing states between the controls. This class can also be used to
create instances of editable geometries from KML (via EGeoXml) or JSON.

Usage: I attempted to make these controls very flexible, given the wide range of possible uses. To that end, the html content
is stored in an html template file (@see #parseMicroTemplate) and contains dynamic elements that can be populated at runtime. In addition,
I also used a very small AOP framework to show how existing functions can be customized, without the need to change the base code, or even
delve into traditional inheritance (@see #aop).

Adds a geometry control to this.controls, which are then added to the map
Note: Would like to use the constructor name of control, so that name is not hard-coded
but inheriting from GControl overrides the original constructor name :(

Is called by GMap2's addOverlay method. Creates the button and appends to the map div.
Since this is called after being added to map, we can access #addControl to add geometry controls and
make them available here.

Loops through all stored geometries by accessing variable for storage
In all of the the controls that have been added.

saveData(opts, geomInfo)

None

Post data for storage to a db. Options to send all information or just one object?

serialize(obj)

None

Serialize JSON to parameters

setLocalTimeout(milliseconds, func)

None

Utility function for executing functions not in global scope

showColorPicker(opts, opts.target, opts.)

None

Create, then store and show/hide an event-bound color picker

toggleButtons(button_name)

None

Turns on selected digitizer button, turns off the other buttons
At the moment, name reference is passed rather than object, is this necessary?

tooltipFactory(tooltip_opts)

Object

Returns a custom tooltip function.
Takes care of one time setup variables and functions and stores then in closure.

zoomToBounds(record)

None

Set map center and zoom to a GBounds

class Geometry

Geometry
A bean for storing geometry data in arrays.
Titles/descriptions are stored as [][0,1] with 0,1 entries representing current(0)/previous(1) values
TODO change title/desc storage to use hash, rather than array

Remember, all init functions get executed from #initialize because zuper isn't defined
until the control is added to zuper, with GeometryControls#addControl, and that's
when initialize is called automatically by GControl

Function that changes styles of the poly that are not set immediately (like colors).

createPolygon(coords, html, opt_currentIndex, opt_currentIcon)

None

Creates (and recreates) polygons

extendGPolygon()

None

Convenience add getter/setters for objects that need translation between stored and displayed value
And do basic input validation (and revert to stored values if values are invalid)
Note: if these methods are eventually added to the api, then these methods will need to be updated
to use call() to access super method.

getDefaultPosition()

None

Expected by GControl, sets control position

hoverTooltip(index)

None

TODO, a mouseover/out implementation for better tooltips (on the polygons)

initialize(map)

DOM Object

Extend for polygon specific implementation

loadPolygons(record)

None

Loads polygons from json

newGPolygon(coords, opts)

None

Convenience method to be able to pass in options as an object

runInitFunctions()

None

Remember, all init functions get executed from #initialize because zuper isn't defined
until the control is added to zuper, with GeometryControls#addControl, and that's
when initialize is called automatically by GControl

startDigitizing()

None

Starts digitizing process, turns on tooltip, calls function for geometry creation
TODO - break up some of the functions?

Function that changes styles of the poly that are not set immediately (like colors).

createPolyline(coords, html, opt_currentIndex, opt_currentIcon)

None

Creates (and recreates) polylines

extendBaseClass()

None

AOP Extensions to the PolylineControl Class
Put All Custom Behaviors here, so that you can swap in new versions of the file
And still have your customizations intact (perhaps they will need tweaking)

extendGPolyline()

None

Convenience add getter/setters for objects that need translation between stored and displayed value
And do basic input validation (and revert to stored values if values are invalid)
Note: if these methods are eventually added to the api, then these methods will need to be updated
to use call() to access super method.

getDefaultPosition()

None

Expected by GControl, sets control position

hoverTooltip(index)

None

TODO, a mouseover/out implementation for better tooltips (on the polylines)

initialize(map)

DOM Object

Extend for polygon specific implementation

loadPolylines(record)

None

Loads polylines from json

newGPolyline(coords, opts)

None

Convenience method to be able to pass in options as an object

runInitFunctions()

None

Remember, all init functions get executed from #initialize because zuper isn't defined
until the control is added to zuper, with GeometryControls#addControl, and that's
when initialize is called automatically by GControl