Version 4.3.6

This commit is contained in:
Neo committed 2025-12-19 05:49:12 -08:00
1 parent fe1acf984a
commit 1a0c7fd3c2
609 files changed
+14707 -5726

No files matched your search

+45 -1
View File
@@ -100,10 +100,11 @@ class _Google extends \IPS\GeoLocation\GeoCoder
* Get the latitude and longitude for the current object. Address must be set.
*
* @param \IPS\GeoLocation $geoLocation Geolocation object
* @param bool $setAddress Whether or not to update the address information from the GeoCoder service
* @return void
* @throws \BadMethodCallException
*/
public function setLatLong( \IPS\GeoLocation &$geoLocation )
public function setLatLong( \IPS\GeoLocation &$geoLocation, $setAddress = FALSE )
{
if ( \IPS\Settings::i()->googlemaps AND \IPS\Settings::i()->google_maps_api_key AND $geoLocation->toString() )
{
@@ -129,6 +130,49 @@ class _Google extends \IPS\GeoLocation\GeoCoder
$geoLocation->lat = $data['results'][0]['geometry']['location']['lat'];
$geoLocation->long = $data['results'][0]['geometry']['location']['lng'];
if( $setAddress === TRUE )
{
$_address = '';
/* Set the address data */
foreach( $data['results'][0]['address_components'] as $component )
{
if( $component['types'][0] == 'street_number' )
{
$_address = $component['long_name'];
}
elseif( $component['types'][0] == 'route' )
{
$_address .= " " . $component['long_name'];
}
if( $component['types'][0] == 'postal_code' )
{
$geoLocation->postalCode = $component['long_name'];
}
if( $component['types'][0] == 'country' )
{
$geoLocation->country = $component['short_name'];
}
if( $component['types'][0] == 'administrative_area_level_1' )
{
$geoLocation->region = $component['long_name'];
}
if( $component['types'][0] == 'locality' )
{
$geoLocation->city = $component['long_name'];
}
}
if( $_address )
{
$geoLocation->addressLines = array( $_address );
}
}
}
else
{