diff --git a/src/Provider/LocationIQ/LocationIQ.php b/src/Provider/LocationIQ/LocationIQ.php index 32a51d8ce..edeb98df4 100644 --- a/src/Provider/LocationIQ/LocationIQ.php +++ b/src/Provider/LocationIQ/LocationIQ.php @@ -120,7 +120,12 @@ private function xmlResultToArray(\DOMElement $resultNode, \DOMElement $addressN foreach (['state', 'county'] as $i => $tagName) { if (null !== ($adminLevel = $this->getNodeValue($addressNode->getElementsByTagName($tagName)))) { - $builder->addAdminLevel($i + 1, $adminLevel, ''); + $adminCode = ''; + if ('state' === $tagName) { + $adminCode = $this->getNodeValue($addressNode->getElementsByTagName('state_code')); + } + + $builder->addAdminLevel($i + 1, $adminLevel, $adminCode); } } @@ -177,7 +182,7 @@ private function executeQuery(string $url, string $locale = null): string private function getGeocodeEndpointUrl(): string { - return self::BASE_API_URL.'/search.php?q=%s&format=xmlv1.1&addressdetails=1&normalizecity=1&limit=%d&key='.$this->apiKey; + return self::BASE_API_URL.'/search.php?q=%s&format=xmlv1.1&addressdetails=1&normalizecity=1&limit=%d&statecode=1&key='.$this->apiKey; } private function getReverseEndpointUrl(): string