Git Product home page Git Product logo

leaflet.tooltip's Introduction

#Leaflet.tooltip

HTML tooltip, supporting a range of configuration options. See the demo.

##Usage

Tooltips are configured with a reference to a Leaflet map and a target which may be an HTML element or a marker instance.

var marker = L.marker(new L.LatLng(-36.852668, 174.762675)).addTo(map);

var tooltip = L.tooltip({
    target: marker,
	map: map,
    html: "I'm a tooltip!"
});

Alternatively this plugin extends the L.Marker class to provide a tooltip option, this should be used exclusively of the title option. The marker's tooltip is configured with a tooltip option which supports all of the tooltip configuration options except target and map which are provided to the tooltip automatically. The same result as above can be written like this:

L.marker(new L.LatLng(-36.852668, 174.762675), {
    tooltip: {
        html: "I'm a tooltip!"
    }
}).addTo(map);

###Options

Option Type Default Description
map L.Map undefined The map instance the tooltip is to be shown on (required).
target HTMLElement/L.Marker undefined The element or marker to bind the tooltip to.
html String undefined The tooltip content. May also be set using the L.Tooltip.setHtml() method.
width mixed 'auto' The width of the tooltip. If unspecified the width will be determined by the tooltip content.
minWidth mixed '' The minimum width of the tooltip specifed as a number or a valid CSS width value.
maxWidth mixed '' The minimum width of the tooltip specifed as a number or a valid CSS width value.
padding mixed '2px 4px' The padding between the tooltip container edge and its content. Specified as a number or a valid CSS padding value.
showDelay Number 500 Delay in milliseconds before the tooltip displays after the mouse enters the target element. Set to 0 for the tooltip to show immediately.
hideDelay Number 500 Delay in milliseconds after the mouse exits the target element but before the tooltip actually hides. Set to 0 for the tooltip to hide immediately.
mouseOffset L.Point L.point(0, 24) An XY offset from the mouse position where the tooltip should be shown.
fadeAnimation Bool true If true the tooltip will be faded in when shown.
trackMouse Bool false If true the tooltip will follow the mouse as it moves over the target element.

###Methods

setTarget(HTMLElement/L.Marker)

Binds the tooltip to the specified element or marker.

setHtml(HTMLElement/String)

Sets the HTML content for the tooltip.

setPosition(L.Point)

Updates the tooltip position.

show(L.Point, HTMLElement/String)

Shows the tooltip at the specified point with the content provided.

hide()

Hides the tooltip.

remove()

Destroys the tooltip and unbinds any event listeners registered.

##License This software is released under the MIT licence.

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.