Overview
TheLatLongFields component is a reusable form input component that provides labeled input fields for entering latitude and longitude coordinates. It’s used by the RouteForm component to handle coordinate entry for both origin and destination points.
Props
Identifier for this field set - used to distinguish between multiple coordinate inputs (e.g., “from” or “to”)
Display label shown above the input fields (e.g., “Desde” for origin or “Hasta” for destination)
Callback function invoked when either coordinate changes. Receives three parameters:
id(string): The field identifier passed as a propfield(string): The coordinate type that changed (“lat” or “lng”)value(number): The new coordinate value
Component Structure
Usage Example
Integration with RouteForm
TheLatLongFields component is used twice in the RouteForm component:
Input Behavior
- Type: Number inputs (
<input type="number">) - Controlled: Component values are controlled by parent state via props
- Change Flow: Input onChange → changeValue() → props.onChange(id, field, value)
- Labels: Spanish text - “Lat:” and “Lon:”
The component uses controlled inputs, meaning all value changes must flow through the parent component’s state management via the
onChange callback.File Location
src/client/LatLongFields.jsx