Class: PopupFeature

ol.Overlay. PopupFeature

A popup element to be displayed on a feature.


new PopupFeature(options)

Parameters:
Name Type Description
options

Extend Popup options

Properties
Name Type Argument Description
popupClass String

the a class of the overlay to style the popup.

closeBox bool

popup has a close box, default false.

onclose: function | undefined

callback function when popup is closed

onshow function | undefined

callback function when popup is shown

offsetBox Number | Array.<number>

an offset box

positionning ol.OverlayPositioning | string | undefined

the 'auto' positioning var the popup choose its positioning to stay on the map.

template Template | function <optional>

A template with a list of properties to use in the popup or a function that takes a feature and returns a Template, default use all feature properties

select ol.interaction.Select

a select interaction to get features from

keepSelection boolean

keep original selection, otherwise set selection to the current popup feature and add a counter to change current feature, default false

canFix boolean

Enable popup to be fixed, default false

showImage boolean

display image url as image, default false

maxChar boolean

max char to display in a cell, default 200

Fires:
  • event:show
  • event:hide
  • event:select

Extends

Methods


<static> localString(locales, options)

Get a function to use as format to get local string for an attribute if the attribute is a number: Number.toLocaleString() if the attribute is a date: Date.toLocaleString() otherwise the attibute itself

Parameters:
Name Type Description
locales string

string with a BCP 47 language tag, or an array of such strings

options *

Number or Date toLocaleString options

Returns:

a function that takes an attribute and return the formated attribute

Type
function

addPopupClass(c)

Add a CSS class to the popup.

Parameters:
Name Type Description
c string

class name.

Inherited From:
Overrides:

getFix()

Is a popup fixed

Returns:
Type
boolean

getVisible()

Check if popup is visible

Inherited From:
Overrides:
Returns:
Type
boolean

hide()

Hide the popup

Inherited From:
Overrides:

removePopupClass(c)

Remove a CSS class to the popup.

Parameters:
Name Type Description
c string

class name.

Inherited From:
Overrides:

setClosebox(b)

Set a close box to the popup.

Parameters:
Name Type Description
b bool
Inherited From:
Overrides:

setFix(fix)

Fix the popup

Parameters:
Name Type Description
fix boolean

setPopupClass(c)

Set the CSS class of the popup.

Parameters:
Name Type Description
c string

class name.

Inherited From:
Overrides:

setPositioning(pos)

Set positionning of the popup

Parameters:
Name Type Description
pos ol.OverlayPositioning | string | undefined

an ol.OverlayPositioning or 'auto' to var the popup choose the best position

Inherited From:
Overrides:

setTemplate( [template])

Set the template

Parameters:
Name Type Argument Description
template Template <optional>

A template with a list of properties to use in the popup, default use all features properties


show(coordinate, features, current)

Show the popup on the map

Parameters:
Name Type Description
coordinate ol.coordinate | undefined

Position of the popup

features ol.Feature | Array.<ol.Feature>

The features on the popup

current ol.Feature

The current feature if keepSelection = true, otherwise get the first feature

Overrides: