ALKMaps.Marker2

Instances of ALKMaps.Marker2 are a combination of a div and other elements.  Markers are generally added to a special layer called ALKMaps.Layer.Markers.

Summary
ALKMaps.Marker2Instances of ALKMaps.Marker2 are a combination of a div and other elements.
Properties
events{ALKMaps.Events} custom events.
id{String} the unique identifier assigned to this marker.
lonlat{ALKMaps.LonLat} location of an object
div{DOMElement}
contentSize{ALKMaps.Size} the width and height of the content.
size{ALKMaps.Size} the width and height of the marker.
contentHTML{String} An HTML string for this marker to display.
backgroundColor{String} the background color used by the marker.
opacity{float} the opacity of this marker (between 0.0 and 1.0)
border{String} the border size of the marker.
contentDiv{DOMElement} a reference to the element that holds the content of the div.
groupDiv{DOMElement} First and only child of ‘div’.
closeDiv{DOMElement} the optional closer image
autoSize{Boolean} Resize the marker to auto-fit the contents.
minSize{ALKMaps.Size} Minimum size allowed for the marker’s contents.
maxSize{ALKMaps.Size} Maximum size allowed for the marker’s contents.
displayClass{String} The CSS class of the marker.
contentDisplayClass{String} The CSS class of the marker content div.
padding{int or ALKMaps.Bounds} An extra opportunity to specify internal padding of the content div inside the marker.
disableFirefoxOverflowHack{Boolean} The hack for overflow in Firefox causes all elements to be re-drawn, which causes Flash elements to be re-initialized, which is troublesome.
map{ALKMaps.Map} this gets set when the marker is added to the map.
attributesAdditional data for popup and clustering.
closeBoxExpose a ‘size’ ALKMaps.Size, ‘displayClass’ {String}, and ‘callback’ {Function}.
Constructor
ALKMaps.Marker2
Functions
destroyDestroy the marker.
fixPaddingTo be removed in 3.0, this function merely helps us to deal with the case where the user may have set an integer value for padding, instead of an ALKMaps.Bounds object.
drawConstructs the elements that make up the marker.
updatePositionif the marker has a lonlat and its map members set, then have it move itself to its proper position
moveTo
visible{Boolean} Boolean indicating whether or not the marker is visible
toggleToggles visibility of the marker.
showMakes the marker visible.
hideMakes the marker invisible.
setVisibilityHide or show marker.
setSizeUsed to adjust the size of the marker.
updateSizeAuto size the marker so that it precisely fits its contents (as determined by this.contentDiv.innerHTML).
setBackgroundColorSets the background color of the marker.
setOpacitySets the opacity of the marker.
setBorderSets the border style of the marker.
setContentHTMLAllows the user to set the HTML content of the marker.
registerImageListenersCalled when an image contained by the marker loaded.
getSafeContentSize
getContentDivPaddingGlorious, oh glorious hack in order to determine the css ‘padding’ of the contentDiv.
addCloseBox
registerEventsRegisters events on the marker.
onmousedownWhen mouse goes down within the marker, make a note of it locally, and then do not propagate the mousedown (but do so safely so that user can select text inside)
onmousemoveIf the drag was started within the marker, then do not propagate the mousemove (but do so safely so that user can select text inside)
onmouseupWhen mouse comes up within the marker, after going down in it, reset the flag, and then (once again) do not propagate the event, but do so safely so that user can select text inside
onclickIgnore clicks, but allowing default browser handling
onmouseoutWhen mouse goes out of the marker set the flag to false so that if they let go and then drag back in, we won’t be confused.
ondblclickIgnore double-clicks, but allowing default browser handling
onmouseoverIgnore mouse over, but allowing default browser handling
createPopupCreate popup and attach it to the marker.
destroyPopupDestroys the popup created via createPopup.
defaulClickHandler

Properties

events

{ALKMaps.Events} custom events.  markerover - Triggered when mouse is over a marker.  Listeners will receive an object with event property.  markerout - Triggered when mouse is out a marker.  Listeners will receive an object with a event property.  markerclick - Triggered when mouse clicks on a marker.  The event object passed to listeners will have event property.

id

{String} the unique identifier assigned to this marker.

lonlat

{ALKMaps.LonLat} location of an object

div

{DOMElement}

contentSize

{ALKMaps.Size} the width and height of the content.

size

{ALKMaps.Size} the width and height of the marker.

contentHTML

{String} An HTML string for this marker to display.

backgroundColor

{String} the background color used by the marker.

opacity

{float} the opacity of this marker (between 0.0 and 1.0)

border

{String} the border size of the marker.  (eg 2px)

contentDiv

{DOMElement} a reference to the element that holds the content of the div.

groupDiv

{DOMElement} First and only child of ‘div’.  The group Div contains the ‘contentDiv’ and the ‘closeDiv’.

closeDiv

{DOMElement} the optional closer image

autoSize

{Boolean} Resize the marker to auto-fit the contents.  Default is false.

minSize

{ALKMaps.Size} Minimum size allowed for the marker’s contents.

maxSize

{ALKMaps.Size} Maximum size allowed for the marker’s contents.

displayClass

{String} The CSS class of the marker.

contentDisplayClass

{String} The CSS class of the marker content div.

padding

{int or ALKMaps.Bounds} An extra opportunity to specify internal padding of the content div inside the marker.  This was originally confused with the css padding as specified in style.css’s ‘olMarkerContent’ class.  We would like to get rid of this altogether, except that it does come in handy for the framed and anchoredbubble markers, who need to maintain yet another barrier between their content and the outer border of the marker itself.

disableFirefoxOverflowHack

{Boolean} The hack for overflow in Firefox causes all elements to be re-drawn, which causes Flash elements to be re-initialized, which is troublesome.  With this property the hack can be disabled.

map

{ALKMaps.Map} this gets set when the marker is added to the map.

attributes

Additional data for popup and clustering.

closeBox

Expose a ‘size’ ALKMaps.Size, ‘displayClass’ {String}, and ‘callback’ {Function}.

Constructor

ALKMaps.Marker2

Parameters

id{String} optional ID.  If it is not provided, the system will create one for a marker.
lonlat{ALKMaps.LonLat} The position of this marker.  Required.
contentSize{ALKMaps.Size} The size of the content.
contentHTML{String} An HTML string to display inside the marker.  If it is null, marker.png icon will be used.
closeBox{Object} If supplied, it should expose a ‘size’ ALKMaps.Size, ‘displayClass’ {String}, and ‘callback’ {Function}.
attributes{Object} Properties for a popup can be added in this.  If an attribute is used for clustering, attach it here.

Note: attributes have following reserved properties

  • popupSize - {ALKMaps.Size} Popup size
  • popupContentHTML - {String} Popup content
  • anchor- {Object} Popup anchor such as { size: new ALKMaps.Size(21,25), offset: new ALKMaps.Pixel(-11,-25)}.  This value is used when a popup is a type of anchored popup.
  • offset - {ALKMaps.Pixel} Popup offset such as {offset: new ALKMaps.Pixel(-11,-25)}.  This value is used when a popup is a type of simple popup.
  • overflow - {String} Popup overflow style such as ‘auto’.

Functions

destroy

destroy: function()

Destroy the marker.  You must first remove the marker from any layer which it has been added to, or you will get buggy behavior.  (This can not be done within the marker since the marker does not know which layer it is attached to.)

fixPadding

fixPadding: function()

To be removed in 3.0, this function merely helps us to deal with the case where the user may have set an integer value for padding, instead of an ALKMaps.Bounds object.

draw

draw: function(px)

Constructs the elements that make up the marker.

Parameters

px{ALKMaps.Pixel} the position the marker in pixels.

Returns

{DOMElement} Reference to a div that contains the drawn marker

updatePosition

updatePosition: function()

if the marker has a lonlat and its map members set, then have it move itself to its proper position

moveTo

moveTo: function(px)

Parameters

px{ALKMaps.Pixel} the top and left position of the marker div.

visible

visible: function()

Returns

{Boolean} Boolean indicating whether or not the marker is visible

toggle

toggle: function()

Toggles visibility of the marker.

show

show: function()

Makes the marker visible.

hide

hide: function()

Makes the marker invisible.

setVisibility

setVisibility: function(visibility)

Hide or show marker.

setSize

setSize:function(contentSize)

Used to adjust the size of the marker.

Parameters

contentSize{ALKMaps.Size} the new size for the marker’s contents div (in pixels).

updateSize

updateSize: function()

Auto size the marker so that it precisely fits its contents (as determined by this.contentDiv.innerHTML). marker size will, of course, be limited by the available space on the current map

setBackgroundColor

setBackgroundColor:function(color)

Sets the background color of the marker.

Parameters

color{String} the background color.  eg “#FFBBBB”

setOpacity

setOpacity:function(opacity)

Sets the opacity of the marker.

Parameters

opacity{float} A value between 0.0 (transparent) and 1.0 (solid).

setBorder

setBorder:function(border)

Sets the border style of the marker.

Parameters

border{String} The border style value. eg 2px

setContentHTML

setContentHTML:function(contentHTML)

Allows the user to set the HTML content of the marker.

Parameters

contentHTML{String} HTML for the div.

registerImageListeners

registerImageListeners: function()

Called when an image contained by the marker loaded. this function updates the marker size, then unregisters the image load listener.

getSafeContentSize

getSafeContentSize: function(size)

Parameters

size{ALKMaps.Size} Desired size to make the marker.

Returns

{ALKMaps.Size} A size to make the marker which is neither smaller than the specified minimum size, nor bigger than the maximum size (which is calculated relative to the size of the viewport).

getContentDivPadding

getContentDivPadding: function()

Glorious, oh glorious hack in order to determine the css ‘padding’ of the contentDiv.  IE/Opera return null here unless we actually add the marker’s main ‘div’ element (which contains contentDiv) to the DOM.  So we make it invisible and then add it to the document temporarily.

Once we’ve taken the padding readings we need, we then remove it from the DOM.

Returns

{ALKMaps.Bounds}

addCloseBox

addCloseBox: function()

registerEvents

registerEvents:function()

Registers events on the marker.

Do this in a separate function so that subclasses can choose to override it if they wish to deal differently with mouse events

Note in the following handler functions that some special care is needed to deal correctly with mousing and markers.

Because the user might select the zoom-rectangle option and then drag it over a marker, we need a safe way to allow the mousemove and mouseup events to pass through the marker when they are initiated from outside.  The same procedure is needed for touchmove and touchend events.

Otherwise, we want to essentially kill the event propagation for all other events, though we have to do so carefully, without disabling basic html functionality, like clicking on hyperlinks or drag-selecting text.

onmousedown

onmousedown: function (evt)

When mouse goes down within the marker, make a note of it locally, and then do not propagate the mousedown (but do so safely so that user can select text inside)

Parameters

evt{Event}

onmousemove

onmousemove: function (evt)

If the drag was started within the marker, then do not propagate the mousemove (but do so safely so that user can select text inside)

Parameters

evt{Event}

onmouseup

onmouseup: function (evt)

When mouse comes up within the marker, after going down in it, reset the flag, and then (once again) do not propagate the event, but do so safely so that user can select text inside

Parameters

evt{Event}

onclick

onclick: function (evt)

Ignore clicks, but allowing default browser handling

Parameters

evt{Event}

onmouseout

onmouseout: function (evt)

When mouse goes out of the marker set the flag to false so that if they let go and then drag back in, we won’t be confused.

Parameters

evt{Event}

ondblclick

ondblclick: function (evt)

Ignore double-clicks, but allowing default browser handling

Parameters

evt{Event}

onmouseover

onmouseover: function(evt)

Ignore mouse over, but allowing default browser handling

Parameters

evt{Event}

createPopup

createPopup: function(closeBox)

Create popup and attach it to the marker.  The popup is created from the marker ‘lonLat’ and ‘popupClass’.  ‘popupSize’, ‘anchor’, ‘popupContentHTML’, and ‘overflow’ properties in this.data can be used to override default popup properties.

If no ‘lonlat’ is set, returns null.

Notethe returned popup object is ‘owned’ by the marker, so you cannot use the popup’s destroy method to discard the popup.  Instead, you must use the marker’s destroyPopup
Notethis.popup is set to return value

Parameters

closeBox{Boolean} create popup with closebox or not

Returns

{ALKMaps.Popup} Returns the created popup, which is also set as ‘popup’ property of this marker.  Will be of whatever type specified by this marker’s ‘popupClass’ property, but must be of type ALKMaps.Popup.

destroyPopup

destroyPopup: function()

Destroys the popup created via createPopup.

As with the marker, if user overrides the createPopup() function, s/he should also be able to override the destruction.

defaulClickHandler

defaulClickHandler: function ()
This class represents a longitude and latitude pair
Instances of this class represent a width/height pair
Instances of this class represent bounding boxes.
Instances of ALKMaps.Map are interactive maps embedded in a web page.
destroy: function()
Destroy the marker.
fixPadding: function()
To be removed in 3.0, this function merely helps us to deal with the case where the user may have set an integer value for padding, instead of an ALKMaps.Bounds object.
draw: function(px)
Constructs the elements that make up the marker.
updatePosition: function()
if the marker has a lonlat and its map members set, then have it move itself to its proper position
moveTo: function(px)
visible: function()
{Boolean} Boolean indicating whether or not the marker is visible
toggle: function()
Toggles visibility of the marker.
show: function()
Makes the marker visible.
hide: function()
Makes the marker invisible.
setVisibility: function(visibility)
Hide or show marker.
setSize:function(contentSize)
Used to adjust the size of the marker.
updateSize: function()
Auto size the marker so that it precisely fits its contents (as determined by this.contentDiv.innerHTML).
setBackgroundColor:function(color)
Sets the background color of the marker.
setOpacity:function(opacity)
Sets the opacity of the marker.
setBorder:function(border)
Sets the border style of the marker.
setContentHTML:function(contentHTML)
Allows the user to set the HTML content of the marker.
registerImageListeners: function()
Called when an image contained by the marker loaded.
getSafeContentSize: function(size)
getContentDivPadding: function()
Glorious, oh glorious hack in order to determine the css ‘padding’ of the contentDiv.
addCloseBox: function()
registerEvents:function()
Registers events on the marker.
onmousedown: function (evt)
When mouse goes down within the marker, make a note of it locally, and then do not propagate the mousedown (but do so safely so that user can select text inside)
onmousemove: function (evt)
If the drag was started within the marker, then do not propagate the mousemove (but do so safely so that user can select text inside)
onmouseup: function (evt)
When mouse comes up within the marker, after going down in it, reset the flag, and then (once again) do not propagate the event, but do so safely so that user can select text inside
onclick: function (evt)
Ignore clicks, but allowing default browser handling
onmouseout: function (evt)
When mouse goes out of the marker set the flag to false so that if they let go and then drag back in, we won’t be confused.
ondblclick: function (evt)
Ignore double-clicks, but allowing default browser handling
onmouseover: function(evt)
Ignore mouse over, but allowing default browser handling
createPopup: function(closeBox)
Create popup and attach it to the marker.
destroyPopup: function()
Destroys the popup created via createPopup.
defaulClickHandler: function ()
This class represents a screen coordinate, in x and y coordinates
A popup is a small div that can opened and closed on the map.
Close