|
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) |
|
|
|
|