Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize Location error for partial postcode search #368

Closed
iamtompickering opened this issue Jan 17, 2023 · 1 comment
Closed

Normalize Location error for partial postcode search #368

iamtompickering opened this issue Jan 17, 2023 · 1 comment
Labels

Comments

@iamtompickering
Copy link

I seem to be hitting the following error when I try and search with specific postcodes both partial and full e.g. 'WN4' or 'WN4 5DH'. Other postcode variations seem to work absolutely fine. but there seems to be some issue with ones that include 'WN'?!

Is there any reason why this would be happening? Screenshot of error below.

CleanShot 2023-01-17 at 09 54 07

@Decyphr
Copy link

Decyphr commented Jun 23, 2023

I also ran into this issue.
It seems to be thrown when $location is a string, but is an invalid GeoService location.

In this case, line 677 $location = self::latLngFromAddress($location, $country); returns null.

I was able to resolve this by adding a null check to the function:
public static function normalizeLocation (mixed $location, string $country = null): array

public static function normalizeLocation (mixed $location, string $country = null): array
{
	if (is_string($location))
		$location = self::latLngFromAddress($location, $country);
	else if ($location instanceof Map)
		$location = ['lat' => $location->lat, 'lng' => $location->lng];
	else if (!is_array($location) || !isset($location['lat'], $location['lng']))
		$location = [];

        // added null check for $location
	if (!$location) {
		$location = [];
	}

	return $location;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants