I have a searchable Leaflet map. The green icons represent all of the existing data and when you search for an address it shows a blue pushpin icon.
I would expect to be able to click anywhere on my custom (blue pushpin) icon and get a popup as a result. But nothing happens when I click on it.
I have to click on a very specific spot in order to get the popup to activate. I can tell it's the right spot because my hover text (on the bottom left) changes. I want to make it so that the results pop up if I click anywhere on the custom icon (or even the original green icon).
I'm using a template, so I'm not completely sure which part of the code controls the hover actions or the "clickable" area, but I'm guessing it's this...?
var hover_template;
$.get( "./templates/hover.ejs", function( template ) {
hover_template = template;
});
SearchableMapLib.info.update = function (props) {
if (props) {
this._div.innerHTML = ejs.render(hover_template, {obj: props});
}
else {
this._div.innerHTML = 'Hover over a ' + SearchableMapLib.recordName;
}
};
SearchableMapLib.info.clear = function(){
this._div.innerHTML = 'Hover over a ' + SearchableMapLib.recordName;
};
question from:
https://stackoverflow.com/questions/66054845/expanding-clickable-area-for-custom-icons-using-leaflet 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…