[ Whereis® API Home ] [ Developers' Guide ] [ Layers ]

A popup is an HTML <div> handled internally by the EMS JavaScript API to display customised content within the map area. Typically, the content relates to some on-map marker or location and is displayed or 'popped up' when the user clicks or mouses over something on or near the map.

Popups are created as divs. There are two benefits to this approach: they can include HTML content and their appearance may be controlled from a CSS file

Having instantiated the popup object, attach it to the map. A popup is always visible when first attached.

Methods

Once initialised, an EMS.Popup object supports various functions, including:

Name

Description

hide()

Make the popup invisible

show()

Make the popup visible

moveTo()

Move the popup to a specified pixel position

updatePosition()

Move the popup to its appropriate geographical position: useful if you want to re-open a popup at its set coordinates after the map has been panned or zoomed

visible()

Determine whether the popup is currently visible. Returns Boolean

The following snippet creates a popup and adds it to an existing map with showPopup and hidePopup functions such as might be triggered by clicking a marker.  

 

var point = new EMS.LonLat(144.965601, -37.81125);

var content = "EMS Popup";

 

var popup = new EMS.Popup("popup-div", point, new OpenLayers.Size(250, 50), content, null, true);

 

map.addPopup(popup);

function showPopup(){

popup.show();

}

function hidePopup(){

popup.hide();

}

NEXT PAGE

NOTES

 

Icon

For more information, see the JavaScript Command Reference and the following working example:

  • Map with popup.