1.3.0 • Published 8 years ago

ol3-popup-umd v1.3.0

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

Build Status view on npm

ol3-popup-umd

Basic popup for an OpenLayers 3 map. By default the map is centered so that the popup is entirely visible. This project originally forked from ol3-popup by Matt Walker and extended with new features like event emitting, additional methods and others, also packed as UMD package.

Installation

Install it thought NPM:

npm install ol3-popup-umd

Or download the latest version archive and add it with script tag:

<script src="ol3-popup-umd/dist/bundle.min.js"></script>

Usage

Plugin is packed into UMD wrapper, import it with CommonJS or ES6:

import PopupOverlay from 'ol3-popup-umd';
const PopupOverlay = require('ol3-popup-umd');

In Browser environment it is available as ol.PopupOverlay.

Demo

Clone or download the repository and open html files from examples directory in a browser. Click on the map to display a popup, click close to the edge of the map to see it pan into view.

API Reference

Typedef

###PopupOptions : Object

Properties

NameTypeDescription
idnumber | string | undefinedSet the overlay id. The overlay id can be used with the ol.Map#getOverlayById method.
offsetnumber[] | undefinedOffsets in pixels used when positioning the overlay. The first element in the array is the horizontal offset. A positive value shifts the overlay right. The second element in the array is the vertical offset. A positive value shifts the overlay down. Default is [0, 0].
positionol.Coordinate | undefinedThe overlay position in map projection.
positioningol.Overlay.Positioning | string | undefinedDefines how the overlay is actually positioned with respect to its position property. Possible values are bottom-left, bottom-center, bottom-right, center-left, center-center, center-right, top-left, top-center, and top-right. Default is top-left.
stopEventboolean | undefinedWhether event propagation to the map viewport should be stopped. Default is true. If true the overlay is placed in the same container as that of the controls (CSS class name ol-overlaycontainer-stopevent); if false it is placed in the container with CSS class name ol-overlaycontainer.
insertFirstboolean | undefinedWhether the overlay is inserted first in the overlay container, or appended. Default is true. If the overlay is placed in the same container as that of the controls (see the stopEvent option) you will probably set insertFirst to true so the overlay is displayed below the controls.
autoPanboolean | undefinedIf set to true the map is panned when calling setPosition, so that the overlay is entirely visible in the current viewport. The default is true.
autoPanAnimationolx.animation.PanOptions | undefinedThe options used to create a ol.animation.pan animation. This animation is only used when autoPan is enabled. Default is { duration: 300, easing: easeInOutCubic }. If set to null the panning is not animated.
autoPanMarginnumber | undefinedThe margin (in pixels) between the overlay and the borders of the map when autopanning. The default is 20.
contentElement | HTMLCollection | string | undefinedPopup initial content.
beforeShowfunction | undefinedFunction that called before popup show. Can be used for show animation.
beforeHidefunction | undefinedFunction that called before popup hide. Can be used for hide animation.

Classes

Popup(options : PopupOptions)

Extends:

  • openlayers~ol.Overlay

Params:

NameTypeDescription
optionsPopupOptionsPopup options.

Members

set content : HTMLCollection

get content : Element

Methods

setContent(content : Element | HTMLCollection | string)

Params:

NameTypeDescription
contentElement | HTMLCollection | stringUpdate popup inner content.

getContent() : Element

Returns:

Element - Inner content of popup.


setMap(map : ol.Map)

Params:

NameTypeDescription
mapol.MapOpenLayers map object.

bringToFront() Show on top of other popups.


show(coordinate : ol.Coordinate,content : Element | HTMLCollection | string) : Promise Shows popup.

Params:

NameTypeDescription
coordinateol.CoordinateNew popup position.
contentElement | HTMLCollection | stringReplace inner content.

Returns:

Promise - Returns Promise that resolves when showing completes.

Events:

  • Popup#show Show event.

hide() : Promise Hides popup.

Returns:

Promise - Returns Promise that resolves when hiding completes.

Events:

  • Popup#hide Hide event.

Credit

Based on ol3-popup by Matt Walker and an example by Tim Schaub posted on the OL3-Dev list.

License

MIT 2016 (c) Matt Walker, Vladimir Vershinin

1.3.0

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago