NYCPlanning / ae-zoning-map-poc

This mapping application shows zoning and other related data on a map of NYC. It is intended as a proof of concept for using React, Deck.gl, Chakra, and other related technologies.
0 stars 0 forks source link

Implement map tax lot selection functionality #43

Open TylerMatteo opened 9 months ago

TylerMatteo commented 9 months ago

When a user has the tax lot district layer on with one or both of the tax lot boundary and land use filters enabled:

Technical requirements:

dhochbaum-dcp commented 8 months ago

@TylerMatteo should any style be added to the tax lot, like an outline or a transparent overlay?

dhochbaum-dcp commented 8 months ago

@TylerMatteo I added the styling to the selection. I was able to complete this without having to add an extra dependency by zooming to the click coordinate.

TODO: Make the map center on the tax lot when someone searches by BBL. I think there will need to be some refactoring to what has been done in this PR in order to complete this. We should probably switch from useGetTaxLotByBbl to useGetTaxLotGeoJsonByBbl, as we will need the GeoJSON data anyway. Restrictions on where you can use hooks may force some refactoring, including potentially breaking out the selected tax lot into a separate MVTLayer. We won't need to add an extra dependency to calculate the center either, as this formula should work fine:

function calculateCentroid(taxLotGeoJson) {
  const minMax = taxLotGeoJson?.geometry.coordinates[0][0].reduce(
    (acc, curr) => {
      return {
        longMin: Math.min(acc.longMin, curr[0]),
        longMax: Math.max(acc.longMax, curr[0]),
        latMin: Math.min(acc.latMin, curr[1]),
        latMax: Math.max(acc.latMax, curr[1]),
      }

    }, { 
      longMin: taxLotGeoJson.geometry.coordinates[0][0][0][0],
      longMax: taxLotGeoJson.geometry.coordinates[0][0][0][0],
      latMin: taxLotGeoJson.geometry.coordinates[0][0][0][1],
      latMax: taxLotGeoJson.geometry.coordinates[0][0][0][1],
    }
  )
  return {
    longitude: (minMax.longMin + minMax.longMax) / 2,
    latitude: (minMax.latMin + minMax.latMax) / 2,
  }
}
dhochbaum-dcp commented 8 months ago

I've created a separate branch which contains all of the changes of the first PR, but also includes the zoom to selected tax lot on performing a search. There's probably a better way to implement this functionality, so let me know if you know of one.