Warp Input demo — phone numbers, addresses, money, IDs, signatures and form helpers for Filament. Change or delete anything; the data is reset every hour. warpui.com About Warp Input Docs Ask a question Support
Skip to content

Pin on a map

->map() on AddressFields adds a map below the address (Leaflet with OpenStreetMap tiles, no key), in place of typing the latitude and longitude by hand. The position is saved in latitude and longitude, the same columns Warp Map reads. This demo sets ->geocoder('nominatim') on the plugin, so clicking the map fills in the address and “Find the address on the map” works. The map’s script (Leaflet, about 160 KB) is only loaded on pages with a map, and ->mapTiles() on the plugin uses your own tile server for heavy traffic. To keep the examples on this page apart, each one saves into its own JSON key.

Click the map to fill in the address

Click the map where the address is: a pin goes there, and the street, city, state and ZIP code of that place are filled in, written the way that country writes them. The second line (apartment, suite) is kept.

Note: Try it

The pin is at Harbor Supply’s warehouse, 200 Atlantic Ave. Type Suite 4 in “Apartment, suite, unit, floor”, then click another street on the map: after a moment the note under the map says “Filled in the address of this place”, Street address and ZIP code change, and Suite 4 stays.

Address

Select an option.

A place without an address

The sea, a mountain or a field has no street or town. The pin still goes there, but the address fields are not changed, and a note says why.

Note: Try it

The map shows Massachusetts Bay. Type 1 Harbor Way in Street address, then click the sea anywhere: the note says there is no address at this place, the pin moves, and Street address still says 1 Harbor Way.

Address

Drag the pin

Drag the pin to move it. When you let go, the address of the new place is filled in, the same as a click.

Note: Try it

Drag the pin at 200 Atlantic Ave a few streets away and let go: Street address and ZIP code change to the new place, and the note under the map shows its address.

Address

Select an option.

Find the typed address on the map

“Find the address on the map” moves the pin to the address in the fields (the apartment line is left out, map services rarely know it). It needs ->geocoder() on the plugin.

Note: Try it

First click “Find the address on the map” with the fields empty: the note asks you to type the address first. Then type 1 Avenue de Lafayette in Street address and Boston in City and click it again: the map zooms in and a pin goes on that street.

Address

Put the pin with the keyboard

For people who use the keyboard: focus the map, move it with the arrow keys, then press “Put the pin in the middle”. The address of the middle of the map is filled in.

Note: Try it

Press Tab until the map has a frame around it. Press → three times to move the map, then Tab to “Put the pin in the middle” and press Enter: the pin moves to the middle of the map, and the address of that place is filled in.

Address

Select an option.

Remove the pin

“Remove the pin” takes the pin away, so the latitude and longitude are saved as null. The address stays.

Note: Try it

Click “Remove the pin”, then “Show what would be saved”: latitude and longitude are null, and 200 Atlantic Ave is still there.

Address

Select an option.

The map follows the postal code

After a postal code fills in the address, the map moves to that area (for countries with GeoNames data). It does not put a pin, because a postal code is not one exact place.

Note: Try it

Type 02110 in ZIP code: City and State are filled in, and the map moves from the whole United States to downtown Boston, without a pin.

Address

Picking a suggestion puts the pin

A picked address suggestion is one exact place, so the pin goes right on it, together with the address.

Note: Try it

Type 200 Atlantic Ave Boston in Street address and pick the suggestion: the address is filled in, and the map zooms in with a pin on 200 Atlantic Avenue.

Address

Saved in latitude and longitude

The position goes to the latitude and longitude columns, rounded to 7 decimals (about 1 cm): $table->decimal('latitude', 10, 7). These are the columns Warp Map’s HasLocation reads, so the customer shows up on your Warp Map right away.

Note: Try it

Type 02110 in ZIP code so the map moves to Boston. Click a street on the map, wait for the address to be filled in, then click “Show what would be saved”: latitude and longitude are next to the address columns.

Address

Inside the JSON column

With ->json('site'), the latitude and longitude are saved inside the JSON too, next to the other parts.

Note: Try it

Type 02110 in ZIP code, click a street on the map and wait for the address, then click “Show what would be saved”: latitude and longitude are inside site.

Site address

Your own column names

->map(latitude: 'lat', longitude: 'lng') saves the position in columns with other names.

Note: Try it

Type 02110 in ZIP code, click a street on the map and wait for the address, then click “Show what would be saved”: the position is in lat and lng.

Branch address