-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show number of active layers on a badge #269
base: main
Are you sure you want to change the base?
Changes from 4 commits
7108446
68738c2
8601df6
ff5b714
9414af2
6958884
2f64322
da8f401
6ee3bc4
c03b0b4
420e2f8
2c5d354
2addd18
863687b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,20 @@ z-index: 10; } | |
padding-bottom: 25px; | ||
margin-right: 65px; | ||
display: inline; | ||
} | ||
|
||
.badge { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, the PR is all set. Only thing is that i think we should move this CSS to /src folder and on grunt build -> we should copy this from /src to /dist folder if it not already there. Makes sense? Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. Shall work on it. Thanks! |
||
width: 30px; | ||
height: 30px; | ||
padding: 4px 2px 0; | ||
border-radius: 50px; | ||
border: 2px solid #908f8f; | ||
background: white; | ||
color: black; | ||
font-weight: bold; | ||
font-size: 1.4em; | ||
margin-left: 80%; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you test if this works on different screen sizes and share screenshot also :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally slipped my mind. Will make sure to test it and share the screenshots. |
||
position: absolute; | ||
text-align: center; | ||
top: 9px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This hard-coded css also, i am not sure if it will work on all screen sizes . |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
L.Control.Badge = L.Control.extend({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add this badge functionality to Readme as well. Telling that this is automatically there if you use otherwise using the above function (which calls listeners) you can add! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay 馃憤 |
||
|
||
initialize: function(content, options) { | ||
this.content = content; | ||
L.setOptions(this, options); | ||
}, | ||
|
||
onAdd: function(map) { | ||
var badgeElement = L.DomUtil.create('div'); | ||
|
||
badgeElement.classList.add('badge'); | ||
badgeElement.innerHTML = this.content; | ||
|
||
return badgeElement; | ||
}, | ||
|
||
onRemove: function(map) { | ||
// Nothing to do here | ||
} | ||
|
||
}); | ||
|
||
L.control.badge = function(content, options) { | ||
return new L.Control.Badge(content, options); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets also add all this code in the /src folder . We want this feature to work when user uses our allLayers feature which automatically adds the menu bar. Makes sense?
This file : https://github.com/publiclab/leaflet-environmental-layers/blob/master/src/AllLayers.js gives the user the ability to add multiple layers. Lets add here also. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create a function of this and call here in example/layers.js and here https://github.com/publiclab/leaflet-environmental-layers/blob/master/src/AllLayers.js .