mapserver/server/static/js/overlays/LabelOverlay.js

36 lines
862 B
JavaScript
Raw Normal View History

2019-04-04 11:49:55 +03:00
/* exported LabelOverlay */
/* globals AbstractIconOverlay: true */
2019-02-08 17:12:40 +03:00
2019-02-26 23:19:01 +03:00
var LabelIcon = L.Icon.extend({
initialize: function(options) {
L.Icon.prototype.initialize.call(this, options);
},
2019-04-04 11:49:55 +03:00
createIcon: function() {
2019-02-26 23:19:01 +03:00
var div = document.createElement('div'),
options = this.options;
div.innerHTML = options.html || "";
return div;
}
});
2019-02-08 17:12:40 +03:00
var LabelOverlay = AbstractIconOverlay.extend({
initialize: function(wsChannel, layerMgr) {
2019-02-08 20:06:16 +03:00
AbstractIconOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "label");
2019-02-08 17:12:40 +03:00
},
getIcon: function(lbl){
2019-02-26 23:19:01 +03:00
return new LabelIcon({
iconAnchor: [15, 50],
iconSize: [30, 100],
html: "<svg height='30' width='100'><text x='0' y='15'>" + lbl.attributes.text + "</text></svg>"
});
2019-02-08 17:12:40 +03:00
},
createPopup: function(lbl){
2019-02-26 23:19:01 +03:00
return "<p>" + lbl.attributes.text + "</p>";
2019-02-08 17:12:40 +03:00
}
});