Skip to main content

upp-address

Address input component with integrated Google Maps modal for geocoding, geolocation, and address validation. It implements ControlValueAccessor for reactive form integration and stores a structured MapAddress object (street, number, locality, coordinates, timezone).

The component is composed of three parts:

  • UppAddressComponent (upp-address) -- The main form control. Displays the formatted address and opens the picker modal on click.
  • UppMdAddressComponent (upp-modal-address) -- The modal dialog. Provides a form with street/number/door/locality fields, a Google Map for visual confirmation, and buttons for geolocation and address validation via the geocode service.
  • UppErAddressComponent (upp-er-address) -- A small validation-error display component that shows error messages for address form controls.

Demo

Source Code

<h2>upp-address</h2>
<p class="demo-description">Delivery address input — shows <code>upp-address</code> with form integration and live value output.</p>

<div class="demo-section" [formGroup]="form">
<h3>Delivery Address</h3>

<div class="demo-note">
<ion-icon name="information-circle-outline"></ion-icon>
Requires Google Maps API key for autocomplete and map display.
</div>

<div class="demo-field">
<label class="demo-label">Address</label>
<upp-address
formControlName="address"
placeholder="Enter delivery address..."
title="Delivery Address">
</upp-address>
</div>
</div>

<!-- Live form value -->
<div class="demo-section">
<h3>Form Value</h3>
<pre class="form-value-output">{{ formValueJson }}</pre>
</div>

API Reference

UppAddressComponent

Selector: upp-address

Inputs

PropertyTypeDefaultDescription
formControlNamestring''Binds the component to a reactive form control via ControlValueAccessor.
placeholderstring''Placeholder text shown when no address is set.
titlestring''Title displayed above the input when an address is selected. Also passed to the modal.
autobooleanfalseWhen true, the address picker modal opens automatically after view init.
errornfoErrorInfo{}Mapping of error keys to human-readable messages, forwarded to the error component.
valuestring | MapAddress | nullnullTwo-way accessor. Reading returns the current MapAddress or string; writing updates the internal value and triggers change callbacks.

Outputs

PropertyTypeDescription
ChangedEventEmitter<MapAddress | null>Fires when the address value changes (after modal selection or programmatic update).

UppMdAddressComponent (Modal)

Selector: upp-modal-address

Opened programmatically by UppAddressComponent.showPicker(). Provides:

  • A reactive form with address, number, door, and locality fields.
  • A Google Map that displays the resolved position and allows click-to-move.
  • Locate button -- uses browser geolocation to resolve the current position.
  • Validate button -- geocodes the form fields to confirm and refine the address.
  • Returns the full MapAddress on accept, or null on dismiss.

Inputs

PropertyTypeDescription
titlestringModal title.
valuestring | MapAddress | nullInitial address. If a MapAddress is provided, the form and map are pre-populated. If a string, it is geocoded on init.

MapAddress Interface

interface MapAddress {
formatted: string;
address: string;
number: string;
door: string | null;
locality: string;
timezone: string;
street: string;
zipcode: string;
town: string;
province: string;
country: string;
accuracy: number;
latitude: number;
longitude: number;
}