Skip to content

shadcn.io is an independent project built on shadcn/ui

Geofence Editor Map Block for Solid

Edit a site fence on a live map: drag corners, add one from any edge, delete one. Area and perimeter update as you drag; machines turn inside or out.

On this page5 sections
UI library: Ark UI

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Draw a fence and see what falls outside it, with this geofence editor map for Solid with Ark UI. Yardkeep, a plant and equipment tracker, puts its fence round a building site at Harmsworth Quays in Canada Water, London, on a live Map that follows your theme, light or dark, with nine tracked machines on and round the site. The fence is a shaded area with a solid outline, a square handle on each corner and a small round handle in the middle of each edge. Drag a corner to move it; drag a round handle, or press it, to add a corner there; click a corner to choose it (it turns solid) and press the bin in the panel to remove it, down to three. While a handle moves, the panel beside the map gives the fence's area and its length round, and the machine list re-checks every machine: inside, or how many metres out, with a dashed badge on the map for each one outside (dashes mean outside, and nothing else). Reset puts the drawn fence back, and Save fence (a Shine Button) keeps it in this demo only. Built from Map, Button, Shine Button and Guides. For fleet and asset tracking, site security, farm and livestock tools, delivery zones and any app with a boundary to keep.

FAQ

How does it know whether a machine is inside?

Each machine's position is tested against the fence with a ray cast: a line drawn east from the machine crosses the fence's edges an odd number of times when it's inside. For a machine outside, the distance is to the nearest point on the nearest edge, in metres. Both are worked out again on every move of a handle, so the list and the badges change as you drag, not after.

How are the area and the perimeter measured?

The perimeter adds the great-circle length of each edge; the area uses the spherical polygon formula mapping tools use, shown in hectares. While you drag a round handle the fence already includes the new corner where it would land, so the figures are what you'd get if you let go there.

Can I edit the fence with a keyboard?

Yes. Every corner and every round handle is in the tab order. A focused corner moves with the arrow keys (hold Shift to go four times as far), and Delete or Backspace removes it and moves focus to the next corner; Enter or a click chooses it for the panel's bin button. A focused round handle adds a corner at the edge's middle with Enter or Space, or where the arrow keys take it. A polite message gives the area, the perimeter and the machines outside once you stop.

Does it work on a phone?

Yes. Drag the handles with a finger; each sits in a larger touch area than it looks. To remove a corner, tap it and then the bin above the figures. The map pans with two fingers, so a one-finger drag on the map scrolls the page instead of moving it. The panel with the figures and the machine list sits under the map.

Where do the fence and the machines come from, and is anything saved?

The site and the streets are real; Yardkeep, the fence's first shape and the nine machines are typed into the file as sample data. Nothing is fetched but the map's tiles, and Save fence only marks the fence as saved: nothing is sent. In your app, save the corners (longitude and latitude pairs) and test your trackers' live positions with the same function.