1
0
forked from MTSR/mapserver

Allow displaying image in POIs (#389)

* Add image to POIs

* fix missing quote

* Swap <hr> position
This commit is contained in:
1F616EMO~nya 2024-06-28 22:32:59 +08:00 committed by GitHub
parent 89ea214d02
commit 070c7f7bdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 9 deletions

View File

@ -18,6 +18,7 @@ func (this *PoiBlock) onMapObject(mbpos *types.MapBlockCoords, x, y, z int, bloc
o.Attributes["name"] = md["name"] o.Attributes["name"] = md["name"]
o.Attributes["category"] = md["category"] o.Attributes["category"] = md["category"]
o.Attributes["url"] = md["url"] o.Attributes["url"] = md["url"]
o.Attributes["image"] = md["image"]
o.Attributes["owner"] = md["owner"] o.Attributes["owner"] = md["owner"]
o.Attributes["icon"] = md["icon"] o.Attributes["icon"] = md["icon"]
o.Attributes["color"] = this.Color o.Attributes["color"] = this.Color

View File

@ -48,3 +48,8 @@ body {
.player-popup div.info { .player-popup div.info {
grid-area: info; grid-area: info;
} }
.poi_image {
width: 100%;
height: auto;
}

View File

@ -20,18 +20,23 @@ export default AbstractIconOverlay.extend({
}, },
createPopup: function(poi){ createPopup: function(poi){
var innerHTML = "";
if (poi.attributes.url) if (poi.attributes.url) {
{ innerHTML += "<a href=\"" + HtmlSanitizer.SanitizeHtml(poi.attributes.url) + "\">" +
return "<a href=\"" + HtmlSanitizer.SanitizeHtml(poi.attributes.url) + "\">" + "<h4>" + HtmlSanitizer.SanitizeHtml(poi.attributes.name) + "</h4></a>";
"<h4>" + HtmlSanitizer.SanitizeHtml(poi.attributes.name) + "</h4></a><hr>" + } else {
"<b>Owner: </b> " + HtmlSanitizer.SanitizeHtml(poi.attributes.owner) + "<br>"; innerHTML += "<h4>" + HtmlSanitizer.SanitizeHtml(poi.attributes.name) + "</h4>";
} }
else
{ if (poi.attributes.image) {
return "<h4>" + HtmlSanitizer.SanitizeHtml(poi.attributes.name) + "</h4><hr>" + innerHTML += "<img class=\"poi_image\" src=\"" + HtmlSanitizer.SanitizeHtml(poi.attributes.image) +
"<b>Owner: </b> " + HtmlSanitizer.SanitizeHtml(poi.attributes.owner) + "<br>"; "\" crossorigin=\"anonymous\" referrerpolicy=\"origin-when-cross-origin\">";
} }
innerHTML += "<hr><b>Owner: </b> " + HtmlSanitizer.SanitizeHtml(poi.attributes.owner) + "<br>";
return innerHTML;
} }