Skip to content

Commit

Permalink
day3: polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosci committed Nov 3, 2021
1 parent 60d4cd0 commit 764eac2
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/lib/LeafletMap.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import curiosity_path from "$lib/data/curiosity_path.json";
import perseverance_path from "$lib/data/perseverance_path.json";
import helicopter_path from "$lib/data/helicopter_path.json";
import mars_montes from "$lib/data/mars_montes.json";
onMount(async () => {
if (browser) {
Expand Down Expand Up @@ -212,6 +213,12 @@
opacity: 0.65,
};
var montesStyle = {
color: "#f2c693",
weight: 5,
opacity: 0.75,
};
var curiosity_line = L.geoJSON(curiosity_path, {
style: roverStyle,
});
Expand All @@ -222,6 +229,24 @@
style: heliStyle,
});
// show name of each element of mars_poly
function onEachFeatures(feature, layer) {
layer.bindPopup(feature.properties.clean_name);
// change layer color
layer.on({
click: function (e) {
e.target.setStyle({
color: "#ff7800",
});
},
});
}
var mars_poly = L.geoJSON(mars_montes, {
style: montesStyle,
onEachFeature: onEachFeatures,
});
helicopter_line.bindTooltip("Perseverance copter flight path");
curiosity_line.bindTooltip("Curiosity rover path");
perseverance_line.bindTooltip("Perseverance rover path");
Expand All @@ -233,16 +258,19 @@
helicopter_line,
]);
var marsMontes = L.featureGroup([mars_poly]);
var overlayMaps = {
"Landing Sites": landingsites,
Curiosity: curiosityPaths,
Perseverance: perseverancePaths,
"Mars Montes": marsMontes,
};
// let s do the actual map
const map = leaflet
.map("map", {
layers: [landingsites, baseMaps.Basemap],
layers: [marsMontes, baseMaps.Basemap],
})
.setView([0, 0], 2.25);
Expand Down Expand Up @@ -276,6 +304,8 @@
map.fitBounds(perseverancePaths.getBounds());
} else if (e.name === "Curiosity") {
map.fitBounds(curiosityPaths.getBounds());
} else if (e.name === "Mars Montes") {
map.fitBounds(curiosityPaths.getBounds());
}
});
}
Expand Down
Loading

0 comments on commit 764eac2

Please sign in to comment.