A popup is a small div that can opened and closed on the map. Typically opened in response to clicking on a marker. See ALKMaps.Marker. Popup’s don’t require their own layer and are added the the map using the ALKMaps.Map.addPopup method.
popup = new ALKMaps.Popup("chicken", new ALKMaps.LonLat(5,40), new ALKMaps.Size(200,200), "example popup", true); map.addPopup(popup);
ALKMaps. | A popup is a small div that can opened and closed on the map. |
Properties | |
events | {ALKMaps.Events} custom event manager |
id | {String} the unique identifier assigned to this popup. |
lonlat | {ALKMaps.LonLat} the position of this popup on the map |
div | {DOMElement} the div that contains this popup. |
contentSize | {ALKMaps.Size} the width and height of the content. |
size | {ALKMaps.Size} the width and height of the popup. |
contentHTML | {String} An HTML string for this popup to display. |
backgroundColor | {String} the background color used by the popup. |
opacity | {float} the opacity of this popup (between 0.0 and 1.0) |
border | {String} the border size of the popup. |
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 popup to auto-fit the contents. |
minSize | {ALKMaps.Size} Minimum size allowed for the popup’s contents. |
maxSize | {ALKMaps.Size} Maximum size allowed for the popup’s contents. |
displayClass | {String} The CSS class of the popup. |
contentDisplayClass | {String} The CSS class of the popup content div. |
padding | {int or ALKMaps.Bounds} An extra opportunity to specify internal padding of the content div inside the popup. |
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. |
Functions | |
fixPadding | 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. |
Properties | |
panMapIfOutOfView | {Boolean} When drawn, pan map such that the entire popup is visible in the current viewport (if necessary). |
keepInMap | {Boolean} If panMapIfOutOfView is false, and this property is true, contrain the popup such that it always fits in the available map space. |
closeOnMove | {Boolean} When map pans, close the popup. |
map | {ALKMaps.Map} this gets set in Map.js when the popup is added to the map |
Constructor | |
ALKMaps. | Create a popup. |
Functions | |
destroy | nullify references to prevent circular references and memory leaks |
draw | Constructs the elements that make up the popup. |
updatePosition | if the popup 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 popup is visible |
toggle | Toggles visibility of the popup. |
show | Makes the popup visible. |
hide | Makes the popup invisible. |
setSize | Used to adjust the size of the popup. |
updateSize | Auto size the popup so that it precisely fits its contents (as determined by this.contentDiv.innerHTML). |
setBackgroundColor | Sets the background color of the popup. |
setOpacity | Sets the opacity of the popup. |
setBorder | Sets the border style of the popup. |
setContentHTML | Allows the user to set the HTML content of the popup. |
registerImageListeners | Called when an image contained by the popup loaded. |
getSafeContentSize | |
getContentDivPadding | Glorious, oh glorious hack in order to determine the css ‘padding’ of the contentDiv. |
addCloseBox | |
panIntoView | Pans the map such that the popup is totally viewable (if necessary) |
registerEvents | Registers events on the popup. |
onmousedown | When mouse goes down within the popup, 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 | If the drag was started within the popup, then do not propagate the mousemove (but do so safely so that user can select text inside) |
onmouseup | When mouse comes up within the popup, 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 | Ignore clicks, but allowing default browser handling |
onmouseout | When mouse goes out of the popup set the flag to false so that if they let go and then drag back in, we won’t be confused. |
ondblclick | Ignore double-clicks, but allowing default browser handling |
{ALKMaps.Events} custom event manager
{ALKMaps.LonLat} the position of this popup on the map
{ALKMaps.Size} the width and height of the content.
{ALKMaps.Size} the width and height of the popup.
{ALKMaps.Size} Minimum size allowed for the popup’s contents.
{ALKMaps.Size} Maximum size allowed for the popup’s contents.
{int or ALKMaps.Bounds} An extra opportunity to specify internal padding of the content div inside the popup. This was originally confused with the css padding as specified in style.css’s ‘olPopupContent’ class. We would like to get rid of this altogether, except that it does come in handy for the framed and anchoredbubble popups, who need to maintain yet another barrier between their content and the outer border of the popup itself.
Note that in order to not break API, we must continue to support this property being set as an integer. Really, though, we’d like to have this specified as a Bounds object so that user can specify distinct left, top, right, bottom paddings. With the 3.0 release we can make this only a bounds.
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.
{Boolean} If panMapIfOutOfView is false, and this property is true, contrain the popup such that it always fits in the available map space. By default, this is not set on the base class. If you are creating popups that are near map edges and not allowing panning, and especially if you have a popup which has a fixedRelativePosition, setting this to false may be a smart thing to do. Subclasses may want to override this setting.
Default is false.
{ALKMaps.Map} this gets set in Map.js when the popup is added to the map
Create a popup.
id | {String} a unique identifier for this popup. If null is passed an identifier will be automatically generated. |
lonlat | {ALKMaps.LonLat} The position on the map the popup will be shown. |
contentSize | {ALKMaps.Size} The size of the content. |
contentHTML | {String} An HTML string to display inside the popup. |
closeBox | {Boolean} Whether to display a close box inside the popup. |
closeBoxCallback | {Function} Function to be called on closeBox click. |
draw: function( px )
Constructs the elements that make up the popup.
px | {ALKMaps.Pixel} the position the popup in pixels. |
{DOMElement} Reference to a div that contains the drawn popup
setSize:function( contentSize )
Used to adjust the size of the popup.
contentSize | {ALKMaps.Size} the new size for the popup’s contents div (in pixels). |
getSafeContentSize: function( size )
size | {ALKMaps.Size} Desired size to make the popup. |
{ALKMaps.Size} A size to make the popup 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: 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 popup’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 (it will actually get added to the DOM in Map.js’s addPopup)
registerEvents:function()
Registers events on the popup.
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 popups.
Because the user might select the zoom-rectangle option and then drag it over a popup, we need a safe way to allow the mousemove and mouseup events to pass through the popup 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.
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.
fixPadding: function()
nullify references to prevent circular references and memory leaks
destroy: function()
Constructs the elements that make up the popup.
draw: function( px )
if the popup has a lonlat and its map members set, then have it move itself to its proper position
updatePosition: function()
moveTo: function( px )
{Boolean} Boolean indicating whether or not the popup is visible
visible: function()
Toggles visibility of the popup.
toggle: function()
Makes the popup visible.
show: function()
Makes the popup invisible.
hide: function()
Used to adjust the size of the popup.
setSize:function( contentSize )
Auto size the popup so that it precisely fits its contents (as determined by this.contentDiv.innerHTML).
updateSize: function()
Sets the background color of the popup.
setBackgroundColor:function( color )
Sets the opacity of the popup.
setOpacity:function( opacity )
Sets the border style of the popup.
setBorder:function( border )
Allows the user to set the HTML content of the popup.
setContentHTML:function( contentHTML )
Called when an image contained by the popup loaded.
registerImageListeners: function()
getSafeContentSize: function( size )
Glorious, oh glorious hack in order to determine the css ‘padding’ of the contentDiv.
getContentDivPadding: function()
addCloseBox: function( callback )
Pans the map such that the popup is totally viewable (if necessary)
panIntoView: function()
Registers events on the popup.
registerEvents:function()
When mouse goes down within the popup, make a note of it locally, and then do not propagate the mousedown (but do so safely so that user can select text inside)
onmousedown: function ( evt )
If the drag was started within the popup, then do not propagate the mousemove (but do so safely so that user can select text inside)
onmousemove: function ( evt )
When mouse comes up within the popup, 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
onmouseup: function ( evt )
Ignore clicks, but allowing default browser handling
onclick: function ( evt )
When mouse goes out of the popup set the flag to false so that if they let go and then drag back in, we won’t be confused.
onmouseout: function ( evt )
Ignore double-clicks, but allowing default browser handling
ondblclick: function ( evt )
addPopup: function( popup, exclusive )