walkermatt/ol-popup
Fork: 43 Star: 163 (更新于 2024-12-12 19:29:21)
license: MIT
Language: JavaScript .
OpenLayers popup overlay
最后发布版本: v5.1.1 ( 2024-05-06 02:09:13)
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, 7, 8 and 9 (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:
-
Basic usage
- Create a popup instance, show it on single-click specifying the content
-
DOM Events
- Handle DOM events triggered by interacting with elements within the popup content
-
Scroll
- Controlling popup dimensions and scrolling overflowing content
-
Multiple popups
- Add a new popup each time the maps is clicked
-
ESM build
- To use the popup with the
ol
package and a module bundler such as Vite, Parcel, Webpack etc. see ol-popup sandbox.
- To use the popup with the
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@latest/dist/ol-popup.js"></script>
CSS
<link rel="stylesheet" href="https://unpkg.com/ol-popup@latest/dist/ol-popup.css" />
ESM
NPM package: ol-popup.
JS
Install the package via npm
npm install ol-popup --save
:warning: 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/dist
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.
最近版本更新:(数据更新于 2024-10-11 10:25:51)
2024-05-06 02:09:13 v5.1.1
2023-06-24 02:53:11 v5.1.0
2015-09-14 03:46:00 v1.0.1
walkermatt/ol-popup同语言 JavaScript最近更新仓库
2024-12-22 13:19:55 gethomepage/homepage
2024-12-22 11:34:40 chris81605/Degrees-of-Lewdity_Cheat_Extended
2024-12-22 00:44:14 gorhill/uBlock
2024-12-21 12:14:02 layui/layui
2024-12-21 03:44:01 emberjs/ember.js
2024-12-20 02:57:09 nodejs/node