Skip to content

Commit

Permalink
fix: Adds missing type declarations (#1698)
Browse files Browse the repository at this point in the history
* Update index.ts

* Update index.ts

* Update index.ts

* Update index.ts

* Update index.ts

* Update index.ts

* Update index.ts
  • Loading branch information
willum070 committed Apr 25, 2024
1 parent 2176c2e commit f9e0f97
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
8 changes: 5 additions & 3 deletions samples/combining-data/index.ts
Expand Up @@ -141,9 +141,11 @@ function styleFeature(feature: google.maps.Data.Feature) {
const low = [5, 69, 54]; // color of smallest datum
const high = [151, 83, 34]; // color of largest datum

let censusVariable = feature.getProperty("census_variable") as number;

// delta represents where the value sits between the min and max
const delta =
(feature.getProperty("census_variable") - censusMin) /
(censusVariable - censusMin) /
(censusMax - censusMin);

const color: number[] = [];
Expand All @@ -157,8 +159,8 @@ function styleFeature(feature: google.maps.Data.Feature) {
let showRow = true;

if (
feature.getProperty("census_variable") == null ||
isNaN(feature.getProperty("census_variable"))
censusVariable == null ||
isNaN(censusVariable)
) {
showRow = false;
}
Expand Down
2 changes: 1 addition & 1 deletion samples/earthquake-circles/index.ts
Expand Up @@ -24,7 +24,7 @@ function initMap(): void {
document.getElementsByTagName("head")[0].appendChild(script);

map.data.setStyle((feature) => {
const magnitude = feature.getProperty("mag");
const magnitude = feature.getProperty("mag") as number;
return {
icon: getCircle(magnitude),
};
Expand Down
2 changes: 1 addition & 1 deletion samples/layer-data-dynamic/index.ts
Expand Up @@ -25,7 +25,7 @@ function initMap(): void {
let color = "gray";

if (feature.getProperty("isColorful")) {
color = feature.getProperty("color");
color = feature.getProperty("color") as string;
}
return /** @type {!google.maps.Data.StyleOptions} */ {
fillColor: color,
Expand Down
2 changes: 1 addition & 1 deletion samples/layer-data-event/index.ts
Expand Up @@ -21,7 +21,7 @@ function initMap(): void {
// Add some style.
map.data.setStyle((feature) => {
return /** @type {google.maps.Data.StyleOptions} */ {
fillColor: feature.getProperty("color"),
fillColor: feature.getProperty("color") as string,
strokeWeight: 1,
};
});
Expand Down
2 changes: 1 addition & 1 deletion samples/layer-data-quakes-red/index.ts
Expand Up @@ -26,7 +26,7 @@ function initMap(): void {

// Add a basic style.
map.data.setStyle((feature) => {
const mag = Math.exp(parseFloat(feature.getProperty("mag"))) * 0.1;
const mag = Math.exp(parseFloat(feature.getProperty("mag") as string)) * 0.1;
return /** @type {google.maps.Data.StyleOptions} */ {
icon: {
path: google.maps.SymbolPath.CIRCLE,
Expand Down
9 changes: 5 additions & 4 deletions samples/layer-data-quakes/index.ts
Expand Up @@ -40,8 +40,9 @@ function styleFeature(feature: google.maps.Data.Feature) {
const maxMag = 6.0;

// fraction represents where the value sits between the min and max
let mag = feature.getProperty("mag") as number;
const fraction =
(Math.min(feature.getProperty("mag"), maxMag) - minMag) / (maxMag - minMag);
(Math.min(mag, maxMag) - minMag) / (maxMag - minMag);

const color = interpolateHsl(low, high, fraction);

Expand All @@ -51,11 +52,11 @@ function styleFeature(feature: google.maps.Data.Feature) {
strokeWeight: 0.5,
strokeColor: "#fff",
fillColor: color,
fillOpacity: 2 / feature.getProperty("mag"),
fillOpacity: 2 / mag,
// while an exponent would technically be correct, quadratic looks nicer
scale: Math.pow(feature.getProperty("mag"), 2),
scale: Math.pow(mag, 2),
},
zIndex: Math.floor(feature.getProperty("mag")),
zIndex: Math.floor(mag),
};
}

Expand Down
2 changes: 1 addition & 1 deletion samples/map-projection-simple/index.ts
Expand Up @@ -40,7 +40,7 @@ function initMap(): void {
// Add some markers to the map.
map.data.setStyle((feature) => {
return {
title: feature.getProperty("name"),
title: feature.getProperty("name") as string,
optimized: false,
};
});
Expand Down

0 comments on commit f9e0f97

Please sign in to comment.