File size: 1,129 Bytes
312b9eb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
from folium.map import Marker
from jinja2 import Template
def set_marker_click_template():
click_marker = """
{% macro script(this, kwargs) %}
function copyToClipboard(text) {
navigator.clipboard.writeText(text).then(function() {
console.log("클립보드에 복사되었습니다: ", text);
}, function(err) {
console.error("클립보드 복사에 실패했습니다: ", err);
});
}
function showToast() {
var toast = document.getElementById("toast");
toast.style.visibility = "visible";
setTimeout(function() {
toast.style.visibility = "hidden";
}, 3000);
}
function onClick(e) {
var marker = e.target;
if (marker.getTooltip()) {
var cellID = marker.getTooltip().getElement().innerText.trim();
copyToClipboard(cellID);
}
}
var {{ this.get_name() }} = L.marker(
{{ this.location|tojson }},
{{ this.options|tojson }}
).addTo({{ this._parent.get_name() }}).on('click', onClick);
{% endmacro %}
"""
Marker._template = Template(click_marker)
|