<?php
namespace Website\Widgets\GoogleMapPro; use Moto; class Widget extends Moto\System\Widgets\AbstractWidget { protected $_name = 'google_map_pro'; protected static $_defaultProperties = array( 'spacing' => array( 'top' => 'auto', 'right' => 'auto', 'bottom' => 'auto', 'left' => 'auto', ), 'visible_on' => 'mobile-v', 'height' => 300, 'params' => array( 'center' => array( 'lat' => 40.7127753, 'lng' => -74.0059728 ), 'zoom' => 10, 'theme' => 'standard', 'mapTypeControl' => true, 'zoomControl' => true, 'streetViewControl' => true, 'rotateControl' => false, 'scaleControl' => false, 'fullscreenControl' => true, ), 'markers' => array() ); protected $_templateType = 'templates'; protected $_widgetId = true; public function init() { $markers = $this->properties['markers']; if (is_array($markers) && count($markers) > 0) { foreach($markers as $index => $marker) { if (array_key_exists('icon', $marker)) { if (is_string($marker['icon']) && $marker['icon'] !== '' && $marker['icon'][0] !== '@' && preg_match('/\/mt-content\/uploads\/(.*)/', $marker['icon'], $match)) { $marker['icon'] = $match[1]; $markers[$index] = $marker; } } } $this->properties['markers'] = $markers; } parent::init(); } public function isSetApiKey() { return Moto\Website\Integration::first('google_map')->api_key; } public function exportFrontendMarkersData() { $markers = $this->properties['markers']; foreach ($markers as $index => $marker) { $markers[$index]['icon'] = Moto\System::getUploadUrl($markers[$index]['icon']); } return json_encode($markers); } } 