• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Code-4-Community / speak-for-the-trees-frontend / 8410875957

24 Mar 2024 05:10PM UTC coverage: 40.976% (+0.08%) from 40.899%
8410875957

push

github

web-flow
Revert "Merge pull request #327 from Code-4-Community/SK.add-map-to-tree-page" (#338)

This reverts commit 504ca7943, reversing
changes made to a9c31c362.

232 of 862 branches covered (26.91%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2 existing lines in 2 files now uncovered.

1078 of 2335 relevant lines covered (46.17%)

11.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

4.76
/src/components/mapComponents/maps/selectorMap/index.tsx
1
import React from 'react';
2
import {
3
  MapViews,
4
  NeighborhoodGeoData,
5
  ReturnMapData,
6
  SiteGeoData,
7
} from '../../ducks/types';
8
import { DEFAULT_CENTER, STREET_ZOOM } from '../../constants';
9

10
import { BasicTreeInfo, NO_SITE_SELECTED } from '../../../treePopup';
11
import MapWithPopup from '../mapWithPopup';
12
import { SiteProps } from '../../../../containers/treePage/ducks/types';
13
import { InitMapData } from '../../ducks/types';
14
import { initSiteView } from '../../logic/init';
15
import { useMapTypeContext } from '../../../../context/mapTypeContext';
16

17
interface SelectorMapProps {
18
  readonly neighborhoods: NeighborhoodGeoData;
19
  readonly sites: SiteGeoData;
20
  readonly onMove: (pos: google.maps.LatLng) => void;
21
  readonly site?: SiteProps;
22
  readonly setMarker: (marker: google.maps.Marker) => void;
23
}
24

25
const SelectorMap: React.FC<SelectorMapProps> = ({
12✔
26
  neighborhoods,
27
  sites,
28
  onMove,
29
  site,
30
  setMarker,
31
}) => {
UNCOV
32
  const defaultZoom = STREET_ZOOM;
×
33

34
  const [, setMapTypeId] = useMapTypeContext();
×
35

36
  const defaultCenter: google.maps.LatLngLiteral = site
×
37
    ? { lat: site.lat, lng: site.lng }
38
    : DEFAULT_CENTER;
39

40
  // BasicTreeInfo to display in tree popup
41
  const basicSite: BasicTreeInfo = {
×
42
    id: NO_SITE_SELECTED,
43
    commonName: '',
44
    address: '',
45
    treePresent: false,
46
  };
47

48
  const setSearchMarkerAndInitSiteMap = (
×
49
    mapData: InitMapData,
50
  ): ReturnMapData => {
51
    const searchMarker = new google.maps.Marker({
×
52
      map: mapData.map,
53
      draggable: true,
54
      position: new google.maps.LatLng(defaultCenter.lat, defaultCenter.lng),
55
    });
56

57
    setMarker(searchMarker);
×
58

59
    google.maps.event.addListener(searchMarker, 'dragend', () => {
×
60
      const latLng = searchMarker.getPosition();
×
61
      if (latLng) {
×
62
        onMove(latLng);
×
63
      }
64
    });
65

66
    const mapLayersAndListeners = initSiteView(
×
67
      mapData,
68
      neighborhoods,
69
      sites,
70
      setMapTypeId,
71
    );
72

73
    const setMapData: ReturnMapData = {
×
74
      map: mapData.map,
75
      zoom: mapData.zoom,
76
      privateStreetsLayer: mapLayersAndListeners.privateStreetsLayer,
77
      neighborhoodsLayer: mapLayersAndListeners.neighborhoodsLayer,
78
      sitesLayer: mapLayersAndListeners.sitesLayer,
79
      searchMarker,
80
      zoomListener: mapLayersAndListeners.zoomListener,
81
      mapTypeListener: mapLayersAndListeners.mapTypeListener,
82
      markersArray: mapData.markersArray,
83
    };
84

85
    mapData.map.setOptions({
×
86
      // Configures the map to react to all user touch input,
87
      // allowing one finger to be used to control map movement rather than page scrolling
88
      gestureHandling: 'greedy',
89
    });
90

91
    return setMapData;
×
92
  };
93

94
  return (
×
95
    <MapWithPopup
96
      zoom={defaultZoom}
97
      view={MapViews.TREES}
98
      lat={defaultCenter.lat}
99
      lng={defaultCenter.lng}
100
      initMap={setSearchMarkerAndInitSiteMap}
101
      defaultActiveTree={basicSite}
102
    />
103
  );
104
};
105

106
export default SelectorMap;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc