Skip to content

Commit 5c4f7af

Browse files
authored
Merge pull request #43 from codeofsumit/develop
Set Icons via CSS
2 parents 5c71011 + 6ba6f3d commit 5c4f7af

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ As we are always using the latest leaflet version in a big production app, I wil
99

1010
### Getting Started
1111

12+
#### Install via npm
13+
`npm install leaflet.pm --save`
14+
1215
#### Install via Bower
1316
`bower install leaflet.pm --save`
1417

src/css/controls.css

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
width: 100%;
1919
}
2020

21+
.leaflet-buttons-control-button img.icon-polygon {
22+
content: url('assets/icons/polygon.png');
23+
}
24+
2125
.leaflet-buttons-control-button:hover {
2226
cursor: pointer;
2327
background-color: #f4f4f4;

src/js/L.Controls.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ L.Control.PMButton = L.Control.extend({
2323

2424
setButton: function (options) {
2525
var button = {
26+
'className': options.className,
2627
'iconUrl': options.iconUrl,
2728
'onClick': options.onClick,
2829
'afterClick': options.afterClick,
@@ -67,7 +68,12 @@ L.Control.PMButton = L.Control.extend({
6768
L.DomUtil.addClass(newButton,'active');
6869

6970
var image = L.DomUtil.create('img', 'control-icon', newButton);
70-
image.setAttribute('src', button.iconUrl);
71+
if (button.iconUrl) {
72+
image.setAttribute('src', button.iconUrl);
73+
}
74+
if (button.className) {
75+
L.DomUtil.addClass(image, button.className);
76+
}
7177

7278
L.DomEvent
7379
.addListener(newButton, 'click', button.onClick, this)

src/js/L.PM.Draw.Poly.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ L.PM.Draw.Poly = L.PM.Draw.extend({
7979
var self = this;
8080

8181
var drawPolyButton = {
82-
'iconUrl': 'assets/icons/polygon.png',
82+
'className': 'icon-polygon',
8383
'onClick': function() {
8484

8585
},

0 commit comments

Comments
 (0)