mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-12 02:10:27 +00:00
Add support for custom geomarker icons
This commit is contained in:
parent
c9f2adc391
commit
3d2ef4ed1a
@ -63,7 +63,7 @@ GeomapWidget.prototype.renderMap = function(domNode) {
|
|||||||
iconHeight = 50;
|
iconHeight = 50;
|
||||||
const myIcon = new L.Icon({
|
const myIcon = new L.Icon({
|
||||||
iconUrl: $tw.utils.makeDataUri(this.wiki.getTiddlerText("$:/plugins/tiddlywiki/geospatial/images/markers/pin"),"image/svg+xml"),
|
iconUrl: $tw.utils.makeDataUri(this.wiki.getTiddlerText("$:/plugins/tiddlywiki/geospatial/images/markers/pin"),"image/svg+xml"),
|
||||||
iconSize: [iconHeight * iconProportions, iconHeight], // Side of the icon
|
iconSize: [iconHeight * iconProportions, iconHeight], // Size of the icon
|
||||||
iconAnchor: [(iconHeight * iconProportions) / 2, iconHeight], // Position of the anchor within the icon
|
iconAnchor: [(iconHeight * iconProportions) / 2, iconHeight], // Position of the anchor within the icon
|
||||||
popupAnchor: [0, -iconHeight] // Position of the popup anchor relative to the icon anchor
|
popupAnchor: [0, -iconHeight] // Position of the popup anchor relative to the icon anchor
|
||||||
});
|
});
|
||||||
@ -92,8 +92,17 @@ GeomapWidget.prototype.renderMap = function(domNode) {
|
|||||||
var lat = $tw.utils.parseNumber(tiddler.fields.lat || "0"),
|
var lat = $tw.utils.parseNumber(tiddler.fields.lat || "0"),
|
||||||
long = $tw.utils.parseNumber(tiddler.fields.long || "0"),
|
long = $tw.utils.parseNumber(tiddler.fields.long || "0"),
|
||||||
alt = $tw.utils.parseNumber(tiddler.fields.alt || "0"),
|
alt = $tw.utils.parseNumber(tiddler.fields.alt || "0"),
|
||||||
caption = tiddler.fields.caption || title;
|
caption = tiddler.fields.caption || title,
|
||||||
var m = L.marker([lat,long,alt],{icon: myIcon,draggable: false}).bindPopup(caption).addTo(map);
|
icon = myIcon;
|
||||||
|
if(tiddler.fields["icon-url"]) {
|
||||||
|
icon = new L.Icon({
|
||||||
|
iconUrl: tiddler.fields["icon-url"],
|
||||||
|
iconSize: [32, 32], // Size of the icon
|
||||||
|
iconAnchor: [16, 32], // Position of the anchor within the icon
|
||||||
|
popupAnchor: [16, -32] // Position of the popup anchor relative to the icon anchor
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var m = L.marker([lat,long,alt],{icon: icon,draggable: false}).bindPopup(caption).addTo(map);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user