Skip to content

Commit

Permalink
Improve typing after PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
richterb committed Aug 19, 2022
1 parent 2a0a57e commit 96d7281
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 5 additions & 3 deletions packages/visualizations/src/components/Map/MapRender.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
NavigationControl,
LngLatBoundsLike,
MapSourceDataEvent,
MapMouseEvent,
MapLayerMouseEvent,
LngLatLike,
} from 'maplibre-gl';
import { onMount } from 'svelte';
Expand Down Expand Up @@ -129,7 +129,9 @@
function sourceLoadingCallback(e: MapSourceDataEvent) {
// sourceDataType can be "visibility" or "metadata", in which case it's not about the data itself
if (e.isSourceLoaded && e.sourceId === sourceId && !e.sourceDataType) {
// @ts-ignore // The type forces you to pass a filter parameter in the option, but it's not required by the real code
// The type forces you to pass a filter parameter in the option, but it's not required by the real code
// https://github.com/maplibre/maplibre-gl-js/issues/1393
// @ts-ignore
const renderedFeatures = map.querySourceFeatures(sourceId, { sourceLayer: layerId });
if (renderedFeatures.length) {
Expand All @@ -151,7 +153,7 @@
}
}
function addTooltip(e: MapMouseEvent) {
function addTooltip(e: MapLayerMouseEvent) {
// @ts-ignore // Somehow `features` isn't part of the type, but exists in the object at runtime
const description = renderTooltip(e.features[0]);
if (hoverPopup.isOpen()) {
Expand Down
10 changes: 8 additions & 2 deletions packages/visualizations/src/components/Map/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ export const colorShapes = (
values: ChoroplethDataValue[],
colorsScale: ColorsScale,
emptyValueColor: Color
) => {
): {
geoJson: FeatureCollection;
bounds: {
min: number;
max: number;
};
} => {
// Key in the values is "x"
// Key in the shapes is "key"
// We add a color property in the JSON
Expand Down Expand Up @@ -140,7 +146,7 @@ function mergeBboxFromFeaturesWithSameKey(features: Feature[]) {
export const computeMaxZoomFromGeoJsonFeatures = (
mapContainer: HTMLElement,
features: Feature[]
) => {
): number => {
let maxZoom = 0; // maxZoom lowest value possible
const filteredBboxes = mergeBboxFromFeaturesWithSameKey(features);
Object.values(filteredBboxes).forEach((value: any) => {
Expand Down

0 comments on commit 96d7281

Please sign in to comment.