GithubHelp home page GithubHelp logo

ol-popup's Introduction

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 3, 4, 5 and 6 (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/[email protected]"></script>

CSS

<link rel="stylesheet" href="https://unpkg.com/[email protected]/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 [email protected].

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 ol.Overlay

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

Parameters

  • opt_options olx.OverlayOptions options as defined by ol.Overlay. Defaults to {autoPan: true, autoPanAnimation: {duration: 250}}

show

Show the popup.

Parameters

  • coord ol.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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.