I would suggest using parse_url in conjunction with a look up table of URLs.
You can do the following:
$allowedReferals = [
'www.google.com/maps',
'www.google.co.uk/maps',
'www.google.in/maps',
];
$referer = !isset($_SERVER['HTTP_REFERER']) ? null : parse_url($_SERVER['HTTP_REFERER']);
if (!is_null($referer)) {
$host = !isset($referer['host']) ? null : $referer['host'];
$path = !isset($referer['path']) ? null : $referer['path'];
$referingDomain = $host . $path;
if (in_array($referingDomain, $allowedReferals)) {
// The referer matches one of the allowed referers in the lookup table
// Do something...
}
if (preg_match('/^maps/', $path)) {
// The referer's path begins with maps
// Do something...
}
}