Skip to content
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

[fix] Set default value for maxZoom and limit maxZoom option #242

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/js/netjsongraph.render.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,36 @@ class NetJSONGraphRender {
if (!self.config.mapTileConfig[0]) {
throw new Error(`You must add the tiles via the "mapTileConfig" param!`);
}
// Add the following lines to set the default maxZoom and make it configurable
self.config.maxZoom = self.config.maxZoom || 12;

if (self.type === "netjson") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's already some identical if statements below, why are you adding more?
Beware of copy pasta code.

self.utils.echartsSetOption(
self.utils.generateMapOption(JSONData, self),
self,
);
self.bboxData = {
nodes: [],
links: [],
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what are these lines for?

} else if (self.type === "geojson") {
const {nodeConfig, linkConfig, baseOptions, ...options} =
self.config.mapOptions;

// Limit the maxZoom option of Leaflet
options.maxZoom = self.config.maxZoom;

self.echarts.setOption({
leaflet: {
tiles: self.config.mapTileConfig,
mapOptions: options,
},
});

self.bboxData = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this for?

features: [],
};
}

if (self.type === "netjson") {
self.utils.echartsSetOption(
Expand Down
Loading