Skip to content

Commit

Permalink
Fix datamaps.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Mar 27, 2021
1 parent 86ed5d5 commit 609cc0e
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 282 deletions.
7 changes: 4 additions & 3 deletions components/common/WorldMap.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import React, { useState, useMemo } from 'react';
import { useRouter } from 'next/router';
import PropTypes from 'prop-types';
import ReactTooltip from 'react-tooltip';
import { ComposableMap, Geographies, Geography, ZoomableGroup } from 'react-simple-maps';
import classNames from 'classnames';
import tinycolor from 'tinycolor2';
import Datamap from 'datamaps';
import useTheme from 'hooks/useTheme';
import { ISO_COUNTRIES, THEME_COLORS } from 'lib/constants';
import { ISO_COUNTRIES, THEME_COLORS, MAP_FILE } from 'lib/constants';
import styles from './WorldMap.module.css';
import useCountryNames from 'hooks/useCountryNames';
import useLocale from 'hooks/useLocale';

function WorldMap({ data, className }) {
const { basePath } = useRouter();
const [tooltip, setTooltip] = useState();
const [theme] = useTheme();
const colors = useMemo(
Expand Down Expand Up @@ -57,7 +58,7 @@ function WorldMap({ data, className }) {
>
<ComposableMap projection="geoMercator">
<ZoomableGroup zoom={0.8} minZoom={0.7} center={[0, 40]}>
<Geographies geography={Datamap.prototype.worldTopo}>
<Geographies geography={`${basePath}${MAP_FILE}`}>
{({ geographies }) => {
return geographies.map(geo => {
const code = ISO_COUNTRIES[geo.id];
Expand Down
2 changes: 2 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export const BROWSERS = {
searchbot: 'Searchbot',
};

export const MAP_FILE = '/datamaps.world.json';

export const ISO_COUNTRIES = {
AFG: 'AF',
ALA: 'AX',
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"classnames": "^2.2.6",
"cookie": "^0.4.1",
"cors": "^2.8.5",
"datamaps": "^0.5.9",
"date-fns": "^2.16.1",
"date-fns-tz": "^1.0.12",
"detect-browser": "^5.2.0",
Expand Down
Loading

0 comments on commit 609cc0e

Please sign in to comment.