All files / src/components/Map types.tsx

0% Statements 0/2
100% Branches 0/0
100% Functions 0/0
0% Lines 0/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89                                                                                                                                                                                 
import { MultiPolygon } from 'geojson';
 
import { IconName } from '../Icon/icons';
 
/**
 * Properties class for GeoJson, with a few reserved object defined.
 */
export type MapProperties = {
  id: string;
  clickable: boolean;
  layerFeatureId: string; // combining layer + feautre ID
  layerId: string; // determines which style to apply
  priority: number;
  [name: string]: any;
};
 
export type MapCursor = 'auto' | 'crosshair' | 'default' | 'pointer' | 'grab';
 
export type MapIconComponentStyle = {
  iconColor: string;
  iconName: IconName;
  type: 'icon';
};
 
export type MapFillComponentStyle = {
  borderColor?: string;
  fillColor?: string;
  fillPatternUrl?: string;
  opacity?: number;
  type: 'fill';
};
 
// Each layer item will become a feature, with a property of id.
export type MapLayerFeature = {
  featureId: string;
  geometry: MultiPolygon;
  label?: string;
  onClick?: () => void;
  priority?: number; // Items with higher priority will be clicked first
  selected?: boolean;
};
 
// Each layer will become a set of features that have the same type.
export type MapLayer = {
  disabled?: boolean;
  features: MapLayerFeature[];
  label: string;
  layerId: string;
  style: MapFillComponentStyle;
};
 
export type MapHighlight = {
  featureIds: { layerId: string; featureId: string }[];
  style: MapFillComponentStyle;
};
 
// Additional shading/annotations for map entities
export type MapHighlightGroup = {
  highlightId: string;
  highlights: MapHighlight[];
};
 
export type MapMarker = {
  id: string; // Must be unique
  longitude: number;
  latitude: number;
  onClick?: () => void;
  selected?: boolean;
};
 
export type MapMarkerGroup = {
  disabled?: boolean;
  label: string;
  markers: MapMarker[];
  markerGroupId: string;
  style: MapIconComponentStyle;
};
 
export type MapViewStyle = 'Outdoors' | 'Satellite' | 'Light' | 'Dark' | 'Streets';
export const MapViewStyles: MapViewStyle[] = ['Outdoors', 'Satellite', 'Light', 'Dark', 'Streets'];
 
export const stylesUrl: Record<MapViewStyle, string> = {
  Outdoors: 'mapbox://styles/mapbox/outdoors-v12?optimize=true',
  Satellite: 'mapbox://styles/mapbox/satellite-streets-v12?optimize=true',
  Streets: 'mapbox://styles/mapbox/streets-v12?optimize=true',
  Light: 'mapbox://styles/mapbox/light-v11?optimize=true',
  Dark: 'mapbox://styles/mapbox/dark-v11?optimize=true',
};