如何显示传单弹出鼠标指针的右侧/左侧

How to display the leaflet popup on the right/left side of mouse pointer?

本文关键字:鼠标指针 左侧 单弹出 何显示 显示      更新时间:2023-09-26

我想在鼠标指针的右侧或左侧显示弹出的传单。默认情况下,它显示在鼠标指针的顶部。

我该怎么做呢?

演示在这里:http://jsfiddle.net/Wn5Kh

<!DOCTYPE html>
<html>
    <head>
        <title>CircleMarker tooltip</title>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="http://leafletjs.com/dist/leaflet.css" />
        <!--[if lte IE 8]>
            <link rel="stylesheet" href="http://leafletjs.com/dist/leaflet.ie.css"
            />
        <![endif]-->
    </head>
    <body>
        <div id="map" style="width: 600px; height: 400px"></div>
        <script src="http://leafletjs.com/dist/leaflet.js"></script>
    </body>
</html>

在leaf .css中可以修改:

.leaflet-popup {
position: absolute;
text-align: center;
}

试着调整一下位置,你会发现你可以改变弹出窗口的打开位置