Skip to content

Commit

Permalink
remove unecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
sarveshpro committed Feb 8, 2021
1 parent fe480be commit 3420d77
Showing 1 changed file with 87 additions and 170 deletions.
257 changes: 87 additions & 170 deletions src/TreeMap/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -82,181 +82,98 @@
map.on("load", () => {
fetchContributionsData.then((contributions) => {
let filteredContributions;
if (community === "true") {
const filteredContributions = contributions;
const geojson = {
type: "FeatureCollection",
features: filteredContributions,
};
map.addSource("contributions", {
type: "geojson",
data: geojson,
cluster: true,
clusterMaxZoom: 14, // Max zoom to cluster points on
clusterRadius: 50, // Radius of each cluster when clustering points (defaults to 50)
clusterProperties: {
sum: ["+", ["to-number", ["get", "treeCount", ["properties"]]]],
},
});
map.addLayer({
id: "contrib-cluster",
type: "circle",
source: "contributions",
filter: ["has", "point_count"],
paint: {
"circle-color": primaryColor,
"circle-radius": ["step", ["get", "sum"], 20, 50, 30, 100, 40],
"circle-stroke-width": 4,
"circle-stroke-color": "#fff",
},
});
map.addLayer({
id: "contrib-cluster-label",
type: "symbol",
source: "contributions",
filter: ["has", "point_count"],
layout: {
"text-field": [
"number-format",
["get", "sum"],
{ "max-fraction-digits": 1 },
],
"text-font": ["Ubuntu Bold"],
"text-size": 12,
},
paint: {
"text-color": "#fff",
},
});
map.addLayer({
id: "contrib",
type: "circle",
source: "contributions",
filter: ["!", ["has", "point_count"]],
paint: {
"circle-color": primaryColor,
"circle-radius": [
"step",
["to-number", ["get", "treeCount"]],
15,
50,
20,
100,
30,
],
"circle-stroke-width": 4,
"circle-stroke-color": "#fff",
},
});
map.addLayer({
id: "contrib-label",
type: "symbol",
source: "contributions",
filter: ["!", ["has", "point_count"]],
layout: {
"text-field": [
"number-format",
["to-number", ["get", "treeCount"]],
{ "max-fraction-digits": 1 },
],
"text-font": ["Ubuntu Bold"],
"text-size": 12,
},
paint: {
"text-color": "#fff",
},
});
filteredContributions = contributions;
} else {
const filteredContributions = contributions.filter((contrib) => {
filteredContributions = contributions.filter((contrib) => {
return contrib.properties.type !== "gift";
});
const geojson = {
type: "FeatureCollection",
features: filteredContributions,
};
map.addSource("contributions", {
type: "geojson",
data: geojson,
cluster: true,
clusterMaxZoom: 14, // Max zoom to cluster points on
clusterRadius: 50, // Radius of each cluster when clustering points (defaults to 50)
clusterProperties: {
sum: ["+", ["to-number", ["get", "treeCount", ["properties"]]]],
},
});
map.addLayer({
id: "contrib-cluster",
type: "circle",
source: "contributions",
filter: ["has", "point_count"],
paint: {
"circle-color": primaryColor,
"circle-radius": ["step", ["get", "sum"], 20, 50, 30, 100, 40],
"circle-stroke-width": 4,
"circle-stroke-color": "#fff",
},
});
map.addLayer({
id: "contrib-cluster-label",
type: "symbol",
source: "contributions",
filter: ["has", "point_count"],
layout: {
"text-field": [
"number-format",
["get", "sum"],
{ "max-fraction-digits": 1 },
],
"text-font": ["Ubuntu Bold"],
"text-size": 12,
},
paint: {
"text-color": "#fff",
},
});
map.addLayer({
id: "contrib",
type: "circle",
source: "contributions",
filter: ["!", ["has", "point_count"]],
paint: {
"circle-color": primaryColor,
"circle-radius": [
"step",
["to-number", ["get", "treeCount"]],
15,
50,
20,
100,
30,
],
"circle-stroke-width": 4,
"circle-stroke-color": "#fff",
},
});
map.addLayer({
id: "contrib-label",
type: "symbol",
source: "contributions",
filter: ["!", ["has", "point_count"]],
layout: {
"text-field": [
"number-format",
["to-number", ["get", "treeCount"]],
{ "max-fraction-digits": 1 },
],
"text-font": ["Ubuntu Bold"],
"text-size": 12,
},
paint: {
"text-color": "#fff",
},
});
}
const geojson = {
type: "FeatureCollection",
features: filteredContributions,
};
map.addSource("contributions", {
type: "geojson",
data: geojson,
cluster: true,
clusterMaxZoom: 14, // Max zoom to cluster points on
clusterRadius: 50, // Radius of each cluster when clustering points (defaults to 50)
clusterProperties: {
sum: ["+", ["to-number", ["get", "treeCount", ["properties"]]]],
},
});
map.addLayer({
id: "contrib-cluster",
type: "circle",
source: "contributions",
filter: ["has", "point_count"],
paint: {
"circle-color": primaryColor,
"circle-radius": ["step", ["get", "sum"], 20, 50, 30, 100, 40],
"circle-stroke-width": 4,
"circle-stroke-color": "#fff",
},
});
map.addLayer({
id: "contrib-cluster-label",
type: "symbol",
source: "contributions",
filter: ["has", "point_count"],
layout: {
"text-field": [
"number-format",
["get", "sum"],
{ "max-fraction-digits": 1 },
],
"text-font": ["Ubuntu Bold"],
"text-size": 12,
},
paint: {
"text-color": "#fff",
},
});
map.addLayer({
id: "contrib",
type: "circle",
source: "contributions",
filter: ["!", ["has", "point_count"]],
paint: {
"circle-color": primaryColor,
"circle-radius": [
"step",
["to-number", ["get", "treeCount"]],
15,
50,
20,
100,
30,
],
"circle-stroke-width": 4,
"circle-stroke-color": "#fff",
},
});
map.addLayer({
id: "contrib-label",
type: "symbol",
source: "contributions",
filter: ["!", ["has", "point_count"]],
layout: {
"text-field": [
"number-format",
["to-number", ["get", "treeCount"]],
{ "max-fraction-digits": 1 },
],
"text-font": ["Ubuntu Bold"],
"text-size": 12,
},
paint: {
"text-color": "#fff",
},
});
});
});
};
Expand Down

0 comments on commit 3420d77

Please sign in to comment.