npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ol-popup-umd

v1.3.1

Published

Popup overlay for OpenLayers with UMD wrapper

Downloads

1

Readme

Build Status view on npm License

ol-popup-umd

Popup overlay for OpenLayers with UMD wrapper

Basic popup for an OpenLayers lib. 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 ol-popup-umd

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

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

Usage

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

import PopupOverlay from 'ol-popup-umd';
const PopupOverlay = require('ol-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

| Name | Type | Description | |:------|:------|:-------------| | id | number | string | undefined | Set the overlay id. The overlay id can be used with the ol.Map#getOverlayById method. | | offset | number[] | undefined | Offsets 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]. | | position | ol.Coordinate | undefined | The overlay position in map projection. | | positioning | ol.Overlay.Positioning | string | undefined | Defines 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. | | stopEvent | boolean | undefined | Whether 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. | | insertFirst | boolean | undefined | Whether 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. | | autoPan | boolean | undefined | If 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. | | autoPanAnimation | olx.animation.PanOptions | undefined | The 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. | | autoPanMargin | number | undefined | The margin (in pixels) between the overlay and the borders of the map when autopanning. The default is 20. | | content | Element | HTMLCollection | string | undefined | Popup initial content. | | beforeShow | function | undefined | Function that called before popup show. Can be used for show animation. | | beforeHide | function | undefined | Function that called before popup hide. Can be used for hide animation. |

Classes

Popup(options : PopupOptions)

Extends:

  • openlayers~ol.Overlay

Params:

| Name | Type | Description | |:------|:------|:-------------| | options | PopupOptions | Popup options. |

Members

set content : HTMLCollection

get content : Element

Methods

setContent(content : Element | HTMLCollection | string)

Params:

| Name | Type | Description | |:------|:------|:-------------| | content | Element | HTMLCollection | string | Update popup inner content. |


getContent() : Element

Returns:

Element - Inner content of popup.


setMap(map : ol.Map)

Params:

| Name | Type | Description | |:------|:------|:-------------| | map | ol.Map | OpenLayers map object. |


bringToFront() Show on top of other popups.


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

Params:

| Name | Type | Description | |:------|:------|:-------------| | coordinate | ol.Coordinate | New popup position. | | content | Element | HTMLCollection | string | Replace 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