-
Notifications
You must be signed in to change notification settings - Fork 93
[feature] Support custom CRS in default config #380 #381
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Added support for custom CRS and used L.CRS.Simple for the indoormap and added selenium test for the indoor map as well. Fixes #380
bd80351
to
253ada2
Compare
Make manual enforce of leaflet disable class Fixes #188
253ada2
to
34618e5
Compare
a87e505
to
b58db81
Compare
const minZoom = self.leaflet.getMinZoom(); | ||
const maxZoom = self.leaflet.getMaxZoom(); | ||
const zoomIn = document.querySelector(".leaflet-control-zoom-in"); | ||
const zoomOut = document.querySelector(".leaflet-control-zoom-out"); | ||
|
||
if (zoomIn && zoomOut) { | ||
if (Math.round(currentZoom) >= maxZoom) { | ||
zoomIn.classList.add("leaflet-disabled"); | ||
} else { | ||
zoomIn.classList.remove("leaflet-disabled"); | ||
} | ||
|
||
if (Math.round(currentZoom) <= minZoom) { | ||
zoomOut.classList.add("leaflet-disabled"); | ||
} else { | ||
zoomOut.classList.remove("leaflet-disabled"); | ||
} | ||
} |
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.
Add some comments in the code why this logic is needed.
In my testing, this scenario only occurs when the min/max zoom level is not a multiple of zoomSnap
.
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.
Good work @dee077!
Let's add some code comments to improve maintainability.
test/netjsongraph.render.test.js
Outdated
document | ||
.querySelectorAll(".leaflet-control-zoom-in, .leaflet-control-zoom-out") | ||
.forEach((el) => el.remove()); | ||
zoomInBtn = document.createElement("a"); | ||
zoomInBtn.className = "leaflet-control-zoom-in"; | ||
zoomOutBtn = document.createElement("a"); | ||
zoomOutBtn.className = "leaflet-control-zoom-out"; | ||
document.body.appendChild(zoomInBtn); | ||
document.body.appendChild(zoomOutBtn); |
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.
Why is it required to remove the existing buttons in DOM and create new buttons?
test/netjsongraph.render.test.js
Outdated
disableClusteringAtLevel: 0, | ||
clusterRadius: 80, |
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.
If clustering is set to false, do these options make sense?
test/netjsongraph.render.test.js
Outdated
expect(document.querySelector(".leaflet-control-zoom-in")).toBe(zoomInBtn); | ||
expect(document.querySelector(".leaflet-control-zoom-out")).toBe( | ||
zoomOutBtn, | ||
); |
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.
Why both these elements should have "leaflet-control-zoom-out" class at the beginning?
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.
Can you add code comments to state the objective of the test (and helper functions)? It is a bit confusing right now.
// set map initial state. | ||
mapOptions: { | ||
center: [48.577, 18.539], | ||
zoom: 5.5, | ||
zoom: 1, |
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 make it 0
@@ -120,37 +121,31 @@ | |||
}, | |||
|
|||
onReady: function presentIndoormap() { | |||
const netjsonmap = this.leaflet; | |||
const netjsonmap = this.leaflet; |
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.
const netjsonmap = this.leaflet; | |
const netjsonmap = this.leaflet; |
There was a blank space at the end of line. You can configure your code editor to automatically remove them upon save.
const bottomRight = netjsonmap.unproject([0, h * 2], zoom); | ||
const upperLeft = netjsonmap.unproject([w * 2, 0], zoom); |
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.
…flet map instead of mocking it
Updates
|
8fc3608
to
82fc8b8
Compare
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.
Looks good to me.
One favour @dee077, there's a red label appearing when hovering the mouse over the nodes which is redundant, can you remove that please?
@pandafy @niteshsinha17 let me know once you think this is ready to merge.
Checklist
Reference to Existing Issue
Closes #380.
Description of Changes
L.CRS.Simple
for the indoor map example and updated the location field accordingly