theme-elements
2 years ago
accordion.php
4 years ago
audio.php
4 years ago
before-after.php
3 years ago
button.php
4 years ago
carousel-navigation.php
4 years ago
circle-chart.php
3 years ago
contact-box.php
4 years ago
contact-form.php
4 years ago
custom-list.php
4 years ago
divider.php
4 years ago
gallery.php
2 years ago
gmap.php
4 years ago
heading-modern.php
3 years ago
icon.php
3 years ago
image.php
4 years ago
mailchimp.php
4 years ago
modern-button.php
4 years ago
products-grid.php
3 years ago
quote.php
4 years ago
recent-comments.php
3 years ago
recent-posts-grid-carousel.php
4 years ago
recent-posts-land-style.php
4 years ago
recent-posts-masonry.php
4 years ago
recent-posts-tiles-carousel.php
4 years ago
recent-posts-tiles.php
4 years ago
recent-posts-timeline.php
4 years ago
recent-products.php
4 years ago
responsive-table.php
3 years ago
search.php
4 years ago
staff.php
4 years ago
svg.php
3 years ago
tabs.php
3 years ago
testimonial.php
4 years ago
text.php
4 years ago
touch-slider.php
4 years ago
video.php
4 years ago
gmap.php
271 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements; |
| 3 | |
| 4 | use Elementor\Widget_Base; |
| 5 | use Elementor\Controls_Manager; |
| 6 | |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly. |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Elementor 'Map' widget. |
| 14 | * |
| 15 | * Elementor widget that displays an 'Map'. |
| 16 | * |
| 17 | * @since 1.0.0 |
| 18 | */ |
| 19 | class Gmap extends Widget_Base { |
| 20 | |
| 21 | /** |
| 22 | * Get widget name. |
| 23 | * |
| 24 | * Retrieve 'Map' widget name. |
| 25 | * |
| 26 | * @since 1.0.0 |
| 27 | * @access public |
| 28 | * |
| 29 | * @return string Widget name. |
| 30 | */ |
| 31 | public function get_name() { |
| 32 | return 'aux_gmap'; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Get widget title. |
| 37 | * |
| 38 | * Retrieve 'Map' widget title. |
| 39 | * |
| 40 | * @since 1.0.0 |
| 41 | * @access public |
| 42 | * |
| 43 | * @return string Widget title. |
| 44 | */ |
| 45 | public function get_title() { |
| 46 | return __( 'Map', 'auxin-elements' ); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Get widget icon. |
| 51 | * |
| 52 | * Retrieve 'Map' widget icon. |
| 53 | * |
| 54 | * @since 1.0.0 |
| 55 | * @access public |
| 56 | * |
| 57 | * @return string Widget icon. |
| 58 | */ |
| 59 | public function get_icon() { |
| 60 | return 'eicon-google-maps auxin-badge'; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Get widget categories. |
| 65 | * |
| 66 | * Retrieve 'Map' widget icon. |
| 67 | * |
| 68 | * @since 1.0.0 |
| 69 | * @access public |
| 70 | * |
| 71 | * @return string Widget icon. |
| 72 | */ |
| 73 | public function get_categories() { |
| 74 | return array( 'auxin-core' ); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Register 'Map' widget controls. |
| 79 | * |
| 80 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 81 | * |
| 82 | * @since 1.0.0 |
| 83 | * @access protected |
| 84 | */ |
| 85 | protected function register_controls() { |
| 86 | |
| 87 | /*-----------------------------------------------------------------------------------*/ |
| 88 | /* map_section |
| 89 | /*-----------------------------------------------------------------------------------*/ |
| 90 | |
| 91 | $this->start_controls_section( |
| 92 | 'map_section', |
| 93 | array( |
| 94 | 'label' => __('Map', 'auxin-elements' ), |
| 95 | ) |
| 96 | ); |
| 97 | |
| 98 | $this->add_control( |
| 99 | 'latitude', |
| 100 | array( |
| 101 | 'label' => __('Latitude','auxin-elements' ), |
| 102 | 'description' => __('Latitude location over the map.', 'auxin-elements' ), |
| 103 | 'type' => Controls_Manager::TEXT, |
| 104 | 'default' => '52' |
| 105 | ) |
| 106 | ); |
| 107 | |
| 108 | $this->add_control( |
| 109 | 'longitude', |
| 110 | array( |
| 111 | 'label' => __('Longitude','auxin-elements' ), |
| 112 | 'description' => __('Longitude location over the map.', 'auxin-elements' ), |
| 113 | 'type' => Controls_Manager::TEXT, |
| 114 | 'default' => '14' |
| 115 | ) |
| 116 | ); |
| 117 | |
| 118 | $this->add_control( |
| 119 | 'marker_info', |
| 120 | array( |
| 121 | 'label' => __('Marker info','auxin-elements' ), |
| 122 | 'description' => __('Marker popup text, leave it empty if you don\'t need it.', 'auxin-elements' ), |
| 123 | 'type' => Controls_Manager::TEXT, |
| 124 | ) |
| 125 | ); |
| 126 | |
| 127 | $this->add_control( |
| 128 | 'attach_id', |
| 129 | array( |
| 130 | 'label' => __('Marker Icon','auxin-elements' ), |
| 131 | 'description' => __('Pick a small icon for gmaps marker.', 'auxin-elements' ), |
| 132 | 'type' => Controls_Manager::MEDIA, |
| 133 | ) |
| 134 | ); |
| 135 | |
| 136 | |
| 137 | $this->end_controls_section(); |
| 138 | |
| 139 | |
| 140 | /*-----------------------------------------------------------------------------------*/ |
| 141 | /* general_section |
| 142 | /*-----------------------------------------------------------------------------------*/ |
| 143 | |
| 144 | $this->start_controls_section( |
| 145 | 'general_section', |
| 146 | array( |
| 147 | 'label' => __('General', 'auxin-elements' ), |
| 148 | 'tab' => Controls_Manager::TAB_STYLE, |
| 149 | ) |
| 150 | ); |
| 151 | |
| 152 | $this->add_control( |
| 153 | 'type', |
| 154 | array( |
| 155 | 'label' => __('Map type', 'auxin-elements'), |
| 156 | 'type' => Controls_Manager::SELECT, |
| 157 | 'default' => 'ROADMAP', |
| 158 | 'options' => array( |
| 159 | 'ROADMAP' => __('Roadmap', 'auxin-elements' ), |
| 160 | 'Satelite' => __('Satelite' , 'auxin-elements' ), |
| 161 | ) |
| 162 | ) |
| 163 | ); |
| 164 | |
| 165 | $this->add_control( |
| 166 | 'height', |
| 167 | array( |
| 168 | 'label' => __('Height','auxin-elements' ), |
| 169 | 'type' => Controls_Manager::TEXT, |
| 170 | 'default' => '700' |
| 171 | ) |
| 172 | ); |
| 173 | |
| 174 | $this->add_control( |
| 175 | 'style', |
| 176 | array( |
| 177 | 'label' => __('Map style','auxin-elements' ), |
| 178 | 'description' => __('This feild allow you to customize the presentation of the standard Google base maps. You can find many preset styles in ', 'auxin-elements' ) . |
| 179 | '<a href="https://snazzymaps.com/" target="_blank">' . __('this website.', 'auxin-elements' ) . '</a>' , |
| 180 | 'type' => Controls_Manager::TEXTAREA , |
| 181 | 'condition' => array( |
| 182 | 'type' => array( 'ROADMAP' ), |
| 183 | ) |
| 184 | ) |
| 185 | ); |
| 186 | |
| 187 | $this->add_control( |
| 188 | 'show_mapcontrols', |
| 189 | array( |
| 190 | 'label' => __('Navigation control','auxin-elements' ), |
| 191 | 'description' => __('Show navigation control on map.','auxin-elements' ), |
| 192 | 'type' => Controls_Manager::SWITCHER, |
| 193 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 194 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 195 | 'return_value' => 'yes', |
| 196 | 'default' => 'yes' |
| 197 | ) |
| 198 | ); |
| 199 | |
| 200 | $this->add_control( |
| 201 | 'zoom', |
| 202 | array( |
| 203 | 'label' => __('Zoom','auxin-elements' ), |
| 204 | 'type' => Controls_Manager::TEXT, |
| 205 | 'default' => '4' |
| 206 | ) |
| 207 | ); |
| 208 | |
| 209 | $this->add_control( |
| 210 | 'zoom_wheel', |
| 211 | array( |
| 212 | 'label' => __('Zoom with mouse wheel','auxin-elements' ), |
| 213 | 'type' => Controls_Manager::SWITCHER, |
| 214 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 215 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 216 | 'return_value' => '1', |
| 217 | 'default' => '0' |
| 218 | ) |
| 219 | ); |
| 220 | |
| 221 | $this->end_controls_section(); |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * Render image box widget output on the frontend. |
| 226 | * |
| 227 | * Written in PHP and used to generate the final HTML. |
| 228 | * |
| 229 | * @since 1.0.0 |
| 230 | * @access protected |
| 231 | */ |
| 232 | protected function render() { |
| 233 | |
| 234 | $settings = $this->get_settings_for_display(); |
| 235 | |
| 236 | |
| 237 | $args = array( |
| 238 | 'type' => $settings['type'], |
| 239 | 'style' => $settings['style'], |
| 240 | 'height' => $settings['height'], |
| 241 | 'latitude' => $settings['latitude'], |
| 242 | 'longitude' => $settings['longitude'], |
| 243 | 'marker_info' => $settings['marker_info'], |
| 244 | 'show_mapcontrols' => $settings['show_mapcontrols'], |
| 245 | 'zoom' => $settings['zoom'], |
| 246 | 'zoom_wheel' => $settings['zoom_wheel'], |
| 247 | 'attach_id' => $settings['attach_id']['id'], |
| 248 | ); |
| 249 | |
| 250 | if( auxin_get_option( 'auxin_google_map_api_key' ) == '' ) { |
| 251 | ob_start(); |
| 252 | ?> |
| 253 | <div class="elementor-alert elementor-alert-danger" role="alert"> |
| 254 | <span class="elementor-alert-title"> |
| 255 | <?php esc_html_e( 'Google Maps API Key Is Missing.', 'auxin-elements' ); ?> |
| 256 | </span> |
| 257 | <span class="elementor-alert-description"> |
| 258 | <?php esc_html_e( 'In order to use google maps on your website, you have to create an api key and insert it in customizer "Google Maps API Key" field.', 'auxin-elements' ); ?> |
| 259 | </span> |
| 260 | </div> |
| 261 | <?php |
| 262 | echo ob_get_clean(); |
| 263 | return; |
| 264 | } |
| 265 | |
| 266 | // get the shortcode base blog page |
| 267 | echo auxin_widget_gmaps_callback( $args ); |
| 268 | } |
| 269 | |
| 270 | } |
| 271 |