Skip to content

Commit

Permalink
Fix Tokyo municipalities flags path
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbarbosa committed Dec 31, 2023
1 parent 4314aec commit 0ad9b11
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions components/Info.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

import { dict } from '../data/dict.js';
import { dict, layers } from '../data/dict.js';
import { furigana } from '../js/furigana.js';
import { state } from '../js/state.js';
import { replaceSpecialChars } from '../js/utils.js';
Expand Down Expand Up @@ -31,7 +31,7 @@ const InfoTooltip = div(
const flagUrl = () => {
const { municipality, city, prefecture } = state;
if (municipality.val) {
return `./img/city/Tokyo,Tokyo.svg`;
return `./img/tokyo/${replaceSpecialChars(municipality.val.name.en)}.svg`;
}
if (city.val) {
return `./img/city/${replaceSpecialChars(city.val.name.en)},${replaceSpecialChars(prefecture.val.name.en)}.svg`;
Expand Down
8 changes: 7 additions & 1 deletion js/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { setCity } from './map/cities.js';
import { clearRegion, resetMap } from './map/regions.js';
import { layers } from '../data/dict.js';
import { state } from './state.js';
import { findCity, findPrefecture } from './regions.js';
import { setPrefecture } from './map/prefectures.js';

/**
* @param {Name} layer
Expand All @@ -21,11 +23,15 @@ export function setLayer(layer) {
if (layer === layers.tokyo) {
resetMap();
clearRegion();
setMunicipalityType();
setPrefecture(findPrefecture('Tokyo'));
setCity(findCity('Tokyo'));
setMunicipalityType(null);
} else if (state.layer.val === layers.tokyo) {
setTimeout(() => {
resetMap();
clearRegion();
setCity(null);
setPrefecture(null);
setMunicipality(null);
}, 1);
}
Expand Down
8 changes: 2 additions & 6 deletions js/map/prefectures.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,10 @@ function improvePrefectureElm(prefecture) {
}

/**
* @param {Prefecture} prefecture
* @param {Prefecture | null} prefecture
*/
export function setPrefecture(prefecture) {
if (!prefecture) {
return;
}

const logicalname = `F#feature#1#0#JP-${prefecture.code}#0`;
const logicalname = prefecture && `F#feature#1#0#JP-${prefecture.code}#0`;

/** @type {NodeListOf<SVGPathElement & { logicalname: string }>} */
const regionsElmCollection = document.querySelectorAll('#regions svg path');
Expand Down

0 comments on commit 0ad9b11

Please sign in to comment.