Skip to content

Commit

Permalink
add movelayer
Browse files Browse the repository at this point in the history
  • Loading branch information
CloudLun committed Dec 12, 2023
1 parent 16268d5 commit 2485d3a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
7 changes: 7 additions & 0 deletions components/Geopanel/Geopanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ const Geopanel = () => {
setDistricts(district)
setSelectedDistrictFeatures(clickedDistrictData.features[0])
setSelectedDistrictOverlappedData((district === "senate" ? senateOverlapped : assemblyOverlapped).filter(d => d.district === clickedDistrictData.features[0]?.properties.District)[0])


// map?.moveLayer("background", "districts")
// map?.moveLayer("background", "pattern")
// map?.moveLayer("pattern", 'districts_outline')
// map?.moveLayer("districts", 'districts_outline')
}

const districtMouseEnverHandler = (e: MouseEvent<HTMLElement>, district: Districts) => {
Expand All @@ -48,6 +54,7 @@ const Geopanel = () => {
type: "FeatureCollection",
features: hoveredDistrctData.features
})

}

const zipcodeMouseEnterHandler = (e: MouseEvent<HTMLElement>) => {
Expand Down
8 changes: 8 additions & 0 deletions components/Map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ const Map = () => {
});








m.addLayer({
'id': 'members',
'type': 'circle',
Expand Down Expand Up @@ -317,9 +323,11 @@ const Map = () => {
m.moveLayer("districts", "counties_borders")
m.moveLayer('pattern', "counties_borders")
m.moveLayer("districts", "zipcodes")
m.moveLayer("pattern", 'districts_outline')
m.moveLayer("pattern", "zipcodes")



m.on("click", "districts", (e: MapMouseEvent & EventData) => {

mapClickHandler(m, e, legislations)
Expand Down
10 changes: 6 additions & 4 deletions context/MapContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const MapProvider = ({ children }: Props) => {
const targetPolygon = turf.polygon([coordinatesArray])
/* @ts-ignore */
let targetCentroid = turf.center(targetPolygon).geometry.coordinates
console.log(targetCentroid)
if(district === 48) targetCentroid[1] = targetCentroid[1] - 0.25
if(district === 49) {
targetCentroid[0] = targetCentroid[0] - 0.275
Expand Down Expand Up @@ -112,18 +111,21 @@ const MapProvider = ({ children }: Props) => {
})

m.moveLayer("districts", "districts_clicked_outline")
m.moveLayer("districts", "districts_outline")
m.moveLayer("districts", "members")
m.moveLayer('districts', "counties_borders")
m.moveLayer('pattern', "counties_borders")
m.moveLayer("pattern", "district_label")
m.moveLayer('pattern', 'districts_outline')
m.moveLayer('pattern', 'districts_clicked_outline')
m.moveLayer('pattern', 'members')
m.moveLayer("background", "zipcodes")
m.moveLayer("districts", "zipcodes")
m.moveLayer("districts_outline", "members")
m.moveLayer('districts_outline', 'districts_clicked_outline')
m.moveLayer("districts_clicked_outline", "members")
m.moveLayer("districts_clicked_outline", "district_label")
m.moveLayer("pattern", "district_label")
m.moveLayer('pattern', 'districts_clicked_outline')
m.moveLayer('pattern', 'members')


setPanelShown({ geopanelShown: true, memberpanelShown: false })
setSelectedDistrictFeatures(e.features[0])
Expand Down

0 comments on commit 2485d3a

Please sign in to comment.