| | |
| | | namespace JVBase\integrations\services; |
| | | use JVBase\integrations\Integrations; |
| | | use JVBase\registrar\Registrar; |
| | | use WP_Error; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | private string $public_key; |
| | | private string $private_key; |
| | | private string $map_id; |
| | | private array $enabled_apis = []; |
| | | |
| | | // Edmonton default coordinates |
| | | private const DEFAULT_LAT = 53.5461; |
| | |
| | | 'key' => $this->private_key |
| | | ]; |
| | | |
| | | $key = $this->cache->generateKey(['geocode', $address]); |
| | | $key =['geocode', $address]; |
| | | $cached = $this->cache->get($key); |
| | | if ($cached) { |
| | | return $cached; |
| | |
| | | 'key' => $this->private_key |
| | | ]; |
| | | |
| | | $key = $this->cache->generateKey(['reverse', $lat, $lng]); |
| | | $key = ['reverse', $lat, $lng]; |
| | | $cached = $this->cache->get($key); |
| | | if ($cached) { |
| | | return $cached; |
| | |
| | | $default_fields = ['name', 'formatted_address', 'geometry', 'rating', 'formatted_phone_number']; |
| | | $fields = empty($fields) ? $default_fields : $fields; |
| | | |
| | | $key = $this->cache->generateKey(['place', $place_id, $fields]); |
| | | $key = ['place', $place_id, $fields]; |
| | | $cached = $this->cache->get($key); |
| | | if ($cached) { |
| | | return $cached; |
| | |
| | | $params['type'] = $type; |
| | | } |
| | | |
| | | $key = $this->cache->generateKey(['nearby', $lat, $lng, $radius, $type]); |
| | | $key = ['nearby', $lat, $lng, $radius, $type]; |
| | | $cached = $this->cache->get($key); |
| | | if ($cached) { |
| | | return $cached; |
| | |
| | | 'key' => $this->private_key |
| | | ]; |
| | | |
| | | $key = $this->cache->generateKey(['distance', $origin_str, $dest_str, $mode]); |
| | | $key = ['distance', $origin_str, $dest_str, $mode]; |
| | | $cached = $this->cache->get($key); |
| | | if ($cached) { |
| | | return $cached; |
| | |
| | | { |
| | | $theme = $this->credentials['theme'] ?? 'default'; |
| | | |
| | | switch ($theme) { |
| | | case 'dark': |
| | | return [ |
| | | ['elementType' => 'geometry', 'stylers' => [['color' => '#242f3e']]], |
| | | ['elementType' => 'labels.text.fill', 'stylers' => [['color' => '#746855']]], |
| | | ['elementType' => 'labels.text.stroke', 'stylers' => [['color' => '#242f3e']]], |
| | | ['featureType' => 'road', 'elementType' => 'geometry', 'stylers' => [['color' => '#38414e']]], |
| | | ['featureType' => 'water', 'elementType' => 'geometry', 'stylers' => [['color' => '#17263c']]] |
| | | ]; |
| | | |
| | | case 'minimal': |
| | | return [ |
| | | ['featureType' => 'poi', 'stylers' => [['visibility' => 'off']]], |
| | | ['featureType' => 'transit', 'stylers' => [['visibility' => 'off']]] |
| | | ]; |
| | | |
| | | default: |
| | | return []; |
| | | } |
| | | return match ($theme) { |
| | | 'dark' => [ |
| | | ['elementType' => 'geometry', 'stylers' => [['color' => '#242f3e']]], |
| | | ['elementType' => 'labels.text.fill', 'stylers' => [['color' => '#746855']]], |
| | | ['elementType' => 'labels.text.stroke', 'stylers' => [['color' => '#242f3e']]], |
| | | ['featureType' => 'road', 'elementType' => 'geometry', 'stylers' => [['color' => '#38414e']]], |
| | | ['featureType' => 'water', 'elementType' => 'geometry', 'stylers' => [['color' => '#17263c']]] |
| | | ], |
| | | 'minimal' => [ |
| | | ['featureType' => 'poi', 'stylers' => [['visibility' => 'off']]], |
| | | ['featureType' => 'transit', 'stylers' => [['visibility' => 'off']]] |
| | | ], |
| | | default => [], |
| | | }; |
| | | } |
| | | |
| | | /** |