ol-popup
TypeScript icon, indicating that this package has built-in type declarations

5.1.0 • Public • Published

OpenLayers Popup

Basic popup overlay for an 'ol' map. By default the map is centred so that the popup is entirely visible.

Compatible with OpenLayers version 5, 6 and 7 (see note in Install - Parcel, Webpack etc. regarding installing the appropriate version of ol-popup for OpenLayers).

Examples

The examples demonstrate usage and can be viewed online thanks to raw.githack.com:

The source for all examples can be found in examples.

Install

Browser

JS

Load ol-popup.js after OpenLayers. The popup overlay is available as Popup or ol.Overlay.Popup.

<script src="https://unpkg.com/ol-popup@5.0.0"></script>

CSS

<link rel="stylesheet" href="https://unpkg.com/ol-popup@5.0.0/src/ol-popup.css" />

Parcel, Webpack etc.

NPM package: ol-popup.

JS

Install the package via npm

npm install ol-popup --save

⚠️ If you're using the ol package prior to v5 you'll need to install ol-popup@v3.0.0.

CSS

The CSS file ol-popup.css can be found in ./node_modules/ol-popup/src

To use the popup with the ol package and a module bundler such as Parcel, Webpack etc. see ol-popup-examples.

API

Table of Contents

Popup

Extends Overlay

OpenLayers Popup Overlay. See the examples for usage. Styling can be done via CSS.

Parameters

  • opt_options ol_Overlay_Options? OpenLayers Overlay options, defaults to {autoPan: {animation: {duration: 250}}}

show

Show the popup.

Parameters
  • coord ol_coordinate_Coordinate Where to anchor the popup.
  • html (String | HTMLElement) String or element of HTML to display within the popup.

Returns Popup The Popup instance

hide

Hide the popup.

Returns Popup The Popup instance

isOpened

Indicates if the popup is in open state

Returns Boolean Whether the popup instance is open

Contributing

Contributions are welcome, please create an issue first to discuss any potential contributions.

Updating README.md

The API section of the README.md is generated from the JSDoc comments in the source code. To update the API docs edit the comments in the code then run:

npm run doc

In order to use the doc npm script you will need to install the devDependencies:

npm install --only=dev

License

MIT (c) Matt Walker.

Credit

Based on an example by Tim Schaub posted on the OL3-Dev list.

Also see

If you find the popup useful you might also like the ol-layerswitcher.

Readme

Keywords

none

Package Sidebar

Install

npm i ol-popup

Weekly Downloads

2,843

Version

5.1.0

License

MIT

Unpacked Size

25.6 kB

Total Files

21

Last publish

Collaborators

  • walkermatt