public function callAddressApi($query) | public function callAddressApi($query) | ||||
{ | { | ||||
if(is_null($query)) { | |||||
$query = ''; | |||||
} | |||||
$resultsToReturn = []; | |||||
if(!is_null($query)) { | |||||
$provider = $this->getGeocoderProvider() ; | |||||
$query = GeocodeQuery::create($query)->withData('type', 'housenumber'); | |||||
$results = $provider->geocodeQuery($query); | |||||
$provider = $this->getGeocoderProvider() ; | |||||
$query = GeocodeQuery::create($query)->withData('type', 'housenumber'); | |||||
$results = $provider->geocodeQuery($query); | |||||
$resultsToReturn = array(); | |||||
foreach($results as $result) { | |||||
if ($result->getStreetNumber() && strlen($result->getStreetNumber()) > 0) { | |||||
$resultsToReturn[] = $result; | |||||
foreach($results as $result) { | |||||
if ($result->getStreetNumber() && strlen($result->getStreetNumber()) > 0) { | |||||
$resultsToReturn[] = $result; | |||||
} | |||||
} | } | ||||
} | } | ||||
return $resultsToReturn; | return $resultsToReturn; | ||||
} | } | ||||
$fieldArray = []; | $fieldArray = []; | ||||
foreach($configureFieldArray as $fieldName) { | foreach($configureFieldArray as $fieldName) { | ||||
if(isset($allFieldArray[$fieldName])) { | if(isset($allFieldArray[$fieldName])) { | ||||
$fieldArray[] = $allFieldArray[$fieldName]; | |||||
$fieldArray[$fieldName] = $allFieldArray[$fieldName]; | |||||
} | } | ||||
else { | else { | ||||
throw new \ErrorException('Le field "'.$fieldName.'" n\'est pas défini dans configureFields()'); | throw new \ErrorException('Le field "'.$fieldName.'" n\'est pas défini dans configureFields()'); |
else return null; | else return null; | ||||
} | } | ||||
static formatNumberWithoutRounding(number, toFixed) { | |||||
if (number){ | |||||
let factor = Math.pow(10, toFixed); | |||||
return Math.floor(number * factor) / factor | |||||
}else{ | |||||
return null | |||||
} | |||||
} | |||||
static formatNumberWithoutFixed(number) { | static formatNumberWithoutFixed(number) { | ||||
if (typeof number == 'string') number = number.replace(',', '.'); | if (typeof number == 'string') number = number.replace(',', '.'); | ||||
if (number) return Number(number); | if (number) return Number(number); |
static setAutoCompleteField() { | static setAutoCompleteField() { | ||||
var autocompleteFields = $('[data-lc-autocomplete-url]'); | var autocompleteFields = $('[data-lc-autocomplete-url]'); | ||||
autocompleteFields.each(function () { | autocompleteFields.each(function () { | ||||
var $this = $(this), | |||||
url = $this.data('lc-autocomplete-url'); | |||||
$this.autoComplete({ | |||||
//bootstrapVersion: 4, | |||||
//noResultsText: 'Aucun résultat n\'a été trouvé.', | |||||
resolverSettings: { | |||||
url: url | |||||
} | |||||
}); | |||||
if(!$(this).hasClass('autocomplete-disabled')) { | |||||
var $this = $(this), | |||||
url = $this.data('lc-autocomplete-url'); | |||||
$this.autoComplete({ | |||||
//bootstrapVersion: 4, | |||||
//noResultsText: 'Aucun résultat n\'a été trouvé.', | |||||
resolverSettings: { | |||||
url: url | |||||
} | |||||
}); | |||||
} | |||||
}); | }); | ||||
} | } | ||||