Latitude and Longitude Validation In Laravel using Regex

Hafiq Iqmal
Geek Culture
Published in
5 min readMar 28, 2023

--

When building web applications that require geolocation data, validating latitude and longitude inputs is a crucial step in ensuring accurate data entry. In this tutorial, we will explore how to validate latitude and longitude inputs in Laravel using regex.

Understanding Latitude and Longitude Coordinates

Latitude and longitude are used to specify a location on the Earth’s surface. Latitude measures how far north or south of the equator a location is, while longitude measures how far east or west of the Prime Meridian a location is.

Latitude and longitude coordinates are typically expressed in decimal degrees format, which is a decimal representation of degrees, minutes, and seconds.

For example, the latitude and longitude coordinates for the Eiffel Tower in Paris are:

Latitude: 48.8584° N
Longitude: 2.2945° E

These coordinates can also be expressed in decimal degrees format as:

Latitude: 48.8584
Longitude: 2.2945

In decimal degrees format, latitude ranges from -90.0 to 90.0, and longitude ranges from -180.0 to 180.0.

Why validate latitude and…

--

--

Hafiq Iqmal
Geek Culture

Technical Lead | Software Engineer | Laravel Enthusiasts | Tech writer | UiTM Alumni | Husband | Proud father of a beautiful daughter