gistda-sphere-react

Rectangle

An axis-aligned box from a corner and a size, with polygon operations

import { Rectangle, SphereMap } from "gistda-sphere-react";

<SphereMap center={{ lon: 100.5, lat: 13.75 }} style={{ height: 400 }} zoom={11}>
  <Rectangle
    position={{ lon: 100.45, lat: 13.8 }}
    size={{ width: 0.1, height: 0.1 }}
    fillColor="rgba(0, 200, 0, 0.3)"
    lineColor="green"
    lineWidth={2}
    title="Area of interest"
  />
</SphereMap>

The shorter samples below leave out <SphereMap>, but every overlay goes inside one.

Props

PropTypeDescription
positionLocationRequired. Top-left corner.
sizeSize | LocationRequired. { width, height } in degrees, or the bottom-right corner.

Rectangles also take the shape props, including editable.

import { Rectangle } from "gistda-sphere-react";

// Both describe the same box:
<Rectangle position={{ lon: 100.45, lat: 13.8 }} size={{ width: 0.1, height: 0.1 }} />
<Rectangle position={{ lon: 100.45, lat: 13.8 }} size={{ lon: 100.55, lat: 13.7 }} />

Ref

Rectangles have the same ref methods as polygons, including getArea, union, intersection, difference and split, plus getRectangle() for the underlying sphere.Rectangle.

On this page