Skip to content

Commit

Permalink
Use default map font
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Apr 7, 2024
1 parent 21b3a97 commit 6b0dfe9
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 29 deletions.
3 changes: 1 addition & 2 deletions src/map/MapGeofence.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useId, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { useTheme } from '@mui/styles';
import { map } from './core/MapView';
import { findFonts, geofenceToFeature } from './core/mapUtil';
import { geofenceToFeature } from './core/mapUtil';
import { useAttributePreference } from '../common/util/preferences';

const MapGeofence = () => {
Expand Down Expand Up @@ -52,7 +52,6 @@ const MapGeofence = () => {
type: 'symbol',
layout: {
'text-field': '{name}',
'text-font': findFonts(map),
'text-size': 12,
},
paint: {
Expand Down
2 changes: 0 additions & 2 deletions src/map/MapMarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useTheme } from '@mui/styles';
import { useMediaQuery } from '@mui/material';
import { map } from './core/MapView';
import { useAttributePreference } from '../common/util/preferences';
import { findFonts } from './core/mapUtil';

const MapMarkers = ({ markers, showTitles }) => {
const id = useId();
Expand Down Expand Up @@ -35,7 +34,6 @@ const MapMarkers = ({ markers, showTitles }) => {
'text-allow-overlap': true,
'text-anchor': 'bottom',
'text-offset': [0, -2 * iconScale],
'text-font': findFonts(map),
'text-size': 12,
},
paint: {
Expand Down
3 changes: 0 additions & 3 deletions src/map/MapPositions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useTheme } from '@mui/styles';
import { map } from './core/MapView';
import { formatTime, getStatusColor } from '../common/util/formatter';
import { mapIconKey } from './core/preloadImages';
import { findFonts } from './core/mapUtil';
import { useAttributePreference, usePreference } from '../common/util/preferences';

const MapPositions = ({ positions, onClick, showStatus, selectedPosition, titleField }) => {
Expand Down Expand Up @@ -115,7 +114,6 @@ const MapPositions = ({ positions, onClick, showStatus, selectedPosition, titleF
'text-allow-overlap': true,
'text-anchor': 'bottom',
'text-offset': [0, -2 * iconScale],
'text-font': findFonts(map),
'text-size': 12,
},
paint: {
Expand Down Expand Up @@ -154,7 +152,6 @@ const MapPositions = ({ positions, onClick, showStatus, selectedPosition, titleF
'icon-image': 'background',
'icon-size': iconScale,
'text-field': '{point_count_abbreviated}',
'text-font': findFonts(map),
'text-size': 14,
},
});
Expand Down
2 changes: 0 additions & 2 deletions src/map/MapRoutePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useTheme } from '@mui/styles';
import { useId, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { map } from './core/MapView';
import { findFonts } from './core/mapUtil';

const MapRoutePath = ({ name, positions, coordinates }) => {
const id = useId();
Expand Down Expand Up @@ -54,7 +53,6 @@ const MapRoutePath = ({ name, positions, coordinates }) => {
type: 'symbol',
layout: {
'text-field': '{name}',
'text-font': findFonts(map),
'text-size': 12,
},
paint: {
Expand Down
18 changes: 0 additions & 18 deletions src/map/core/mapUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,3 @@ export const geofenceToFeature = (theme, item) => {
};

export const geometryToArea = (geometry) => stringify(reverseCoordinates(geometry));

export const findFonts = (map) => {
const fontSet = new Set();
const { layers } = map.getStyle();
layers?.forEach?.((layer) => {
layer.layout?.['text-font']?.forEach?.(fontSet.add, fontSet);
});
const availableFonts = [...fontSet];
const regularFont = availableFonts.find((it) => it.includes('Regular'));
if (regularFont) {
return [regularFont];
}
const anyFont = availableFonts.find(Boolean);
if (anyFont) {
return [anyFont];
}
return ['Roboto Regular'];
};
2 changes: 0 additions & 2 deletions src/map/main/PoiMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useTheme } from '@mui/styles';
import { map } from '../core/MapView';
import { useEffectAsync } from '../../reactHelper';
import { usePreference } from '../../common/util/preferences';
import { findFonts } from '../core/mapUtil';

const PoiMap = () => {
const id = useId();
Expand Down Expand Up @@ -55,7 +54,6 @@ const PoiMap = () => {
'text-field': '{name}',
'text-anchor': 'bottom',
'text-offset': [0, -0.5],
'text-font': findFonts(map),
'text-size': 12,
},
paint: {
Expand Down

0 comments on commit 6b0dfe9

Please sign in to comment.