Skip to content

Instantly share code, notes, and snippets.

@typpo
Created August 3, 2013 00:20
Show Gist options
  • Select an option

  • Save typpo/6144460 to your computer and use it in GitHub Desktop.

Select an option

Save typpo/6144460 to your computer and use it in GitHub Desktop.
/*
* Support for putting text on a marker
* @author akearney
*/
L.TextIcon = L.Icon.extend({
options: {
iconUrl: undefined,
text: undefined,
},
createIcon: function() {
var me = this;
me.div = document.createElement('div');
var text = document.createElement('div');
me.$text = $(text);
me.img = me._createImg(me.options.iconUrl);
me.$text.html(me.options.text);
me.$text.addClass('marker_text');
me.div.appendChild(me.img);
me.div.appendChild(text);
me._setIconStyles(me.div, 'icon');
return me.div;
},
changeText: function(newText) {
var me = this;
me.$text.html(newText);
me.options.text = newText;
},
changeImage: function(newUrl) {
var me = this;
me.img = me._createImg(newUrl);
me.options.iconUrl = newUrl;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment