geocoder-php/GeocoderLaravel

Restrict/Force prioritise to UK/Ireland

MajorasJack opened this issue · 1 comments

General Information

GeocoderLaravel Version: 4.0
Laravel Version: 5.4.36
PHP Version: 7.1
Operating System and Version: Ubuntu 16.04

Issue Description

Is there any way to restrict the GeoCoder to only search in, say, England and Ireland.

Steps to Replicate

Added to config/geocoder.php

return [
    'cache-duration' => 999999999,
    'providers' => [
        Chain::class => [
            GoogleMaps::class => [
                'en-GB',
                env('GOOGLE_MAPS_API_KEY'),
            ],
            GeoPlugin::class  => [],
        ],
    ],
    'adapter'  => Client::class,
];

Search 'York', returned Collection is:

#items: array:1 [▼
    0 => GoogleAddress {#530 ▼
      -id: "ChIJYYWuV8GLyIkRzRPyXur6rBo"
      -locationType: "APPROXIMATE"
      -resultType: array:2 [▶]
      -formattedAddress: "York, PA, USA"
      -streetAddress: null
      -intersection: null
      -political: "United States"
      -colloquialArea: null
      -ward: null
      -neighborhood: null
      -premise: null
      -subpremise: null
      -naturalFeature: null
      -airport: null
      -park: null
      -pointOfInterest: null
      -establishment: null
      -subLocalityLevels: AdminLevelCollection {#531 ▶}
      -coordinates: Coordinates {#532 ▼
        -latitude: 39.9625984
        -longitude: -76.727745
      }
      -bounds: Bounds {#533 ▶}
      -streetNumber: null
      -streetName: null
      -subLocality: null
      -locality: "York"
      -postalCode: null
      -adminLevels: AdminLevelCollection {#534 ▶}
      -country: Country {#537 ▼
        -name: "United States"
        -code: "US"
      }
      -timezone: null
      -providedBy: "google_maps"
    }
  ]

Where the desired/expected result would be York, UK

Stack Trace

N/A

You will need to consult the Google Maps docs, as well as the Geocoder plugin docs to see if this can be done. This package is more or less a wrapper on that package to tie it in closely to Laravel, and does not affect that functionality.

Some links that might shed some light:
https://stackoverflow.com/questions/19026856/get-only-country-specific-result-using-google-geocode-api

My recommendation would be to ask this question in the geocoder-php repo:
https://github.com/geocoder-php/Geocoder/issues

Good luck! Let me know what you find out... it may be worth documenting somewhere.