react-simple-maps icon indicating copy to clipboard operation
react-simple-maps copied to clipboard

Display and center only a single state from a full US counties map

Open neverbe10 opened this issue 5 years ago • 0 comments

Hi

I'm currently using us-albers topojson map, and I wonder if there is a way to get one state from full US map. Here is my attempt in sandbox. I'm able to filter out the geometries to a single state using the following code, but I'm having trouble centering single on a single state:

function getGeo(state) {
  if (!state) {
    return geo;
  }
  const { type, bbox, transform, objects, arcs } = geo;

  const { states, nation } = objects;

  return {
    type,
    bbox,
    transform,
    objects: {
      states: {
        type: "GeometryCollection",
        geometries: states.geometries.filter(n => n.properties.abbr === state)
      }
    },
    arcs,
    nation
  };
}

Related Issues:

  • #95

neverbe10 avatar Apr 22 '20 07:04 neverbe10