# Code coverage report for src/layer/marker/DivIcon.js

## Statements: 18.18% (2 / 11) Branches: 0% (0 / 4) Functions: 0% (0 / 3) Lines: 18.18% (2 / 11)

All files » src/layer/marker/ » DivIcon.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43

    1

    1

     /*
     * L.DivIcon is a lightweight HTML-based icon class (as opposed to the image-based L.Icon)
     * to use with L.Marker.
     */

    L.DivIcon = L.Icon.extend({
    	options: {
    		iconSize: new L.Point(12, 12), // also can be set through CSS
    		/*
    		iconAnchor: (Point)
    		popupAnchor: (Point)
    		html: (String)
    		bgPos: (Point)
    		*/
    		className: 'leaflet-div-icon'
    	},

    	createIcon: function () {
    		var div = document.createElement('div'),
    		    options = this.options;

    		if (options.html) {
    			div.innerHTML = options.html;
    		}

    		if (options.bgPos) {
    			div.style.backgroundPosition =
    			        (-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px';
    		}

    		this._setIconStyles(div, 'icon');
    		return div;
    	},

    	createShadow: function () {
    		return null;
    	}
    });

    L.divIcon = function (options) {
    	return new L.DivIcon(options);
    };