start_controls_section( 'section_map', [ 'label' => __( 'Map Settings', 'admore-widgets-suite' ), ] ); $this->add_control( 'api_key', [ 'label' => __( 'Google Maps API Key', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'placeholder' => __( 'AIzaSy...', 'admore-widgets-suite' ), 'description' => __( 'Get your API key from Google Cloud Console. Required for custom styling and markers.', 'admore-widgets-suite' ), 'label_block' => true, ] ); $this->add_control( 'embed_type', [ 'label' => __( 'Embed Type', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'place', 'options' => [ 'place' => __( 'Place / Address', 'admore-widgets-suite' ), 'coordinates' => __( 'Coordinates (Lat, Lng)', 'admore-widgets-suite' ), 'directions' => __( 'Directions', 'admore-widgets-suite' ), ], ] ); $this->add_control( 'address', [ 'label' => __( 'Address', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => 'New York, NY, USA', 'label_block' => true, 'condition' => [ 'embed_type' => 'place' ], 'dynamic' => [ 'active' => true ], ] ); $this->add_control( 'latitude', [ 'label' => __( 'Latitude', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '40.7128', 'condition' => [ 'embed_type' => 'coordinates' ], ] ); $this->add_control( 'longitude', [ 'label' => __( 'Longitude', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '-74.0060', 'condition' => [ 'embed_type' => 'coordinates' ], ] ); $this->add_control( 'origin', [ 'label' => __( 'Origin', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', 'condition' => [ 'embed_type' => 'directions' ], 'dynamic' => [ 'active' => true ], ] ); $this->add_control( 'destination', [ 'label' => __( 'Destination', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', 'condition' => [ 'embed_type' => 'directions' ], 'dynamic' => [ 'active' => true ], ] ); $this->add_control( 'zoom', [ 'label' => __( 'Zoom Level', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 1, 'max' => 21 ] ], 'default' => [ 'size' => 14 ], ] ); $this->add_control( 'map_type', [ 'label' => __( 'Map Type', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'roadmap', 'options' => [ 'roadmap' => __( 'Roadmap', 'admore-widgets-suite' ), 'satellite' => __( 'Satellite', 'admore-widgets-suite' ), 'hybrid' => __( 'Hybrid', 'admore-widgets-suite' ), 'terrain' => __( 'Terrain', 'admore-widgets-suite' ), ], ] ); $this->add_control( 'language', [ 'label' => __( 'Language', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => 'en', ] ); $this->add_control( 'disable_scroll_zoom', [ 'label' => __( 'Disable Scroll Zoom', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => '', 'return_value' => 'yes', 'description' => __( 'Shows a click-to-activate overlay so page scroll does not zoom the map.', 'admore-widgets-suite' ), 'separator' => 'before', ] ); $this->add_control( 'click_to_activate_text', [ 'label' => __( 'Click-to-Activate Text', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'Click to interact with map', 'admore-widgets-suite' ), 'condition' => [ 'disable_scroll_zoom' => 'yes' ], ] ); $this->add_control( 'map_style', [ 'label' => __( 'Map Style', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'default', 'options' => [ 'default' => __( 'Default', 'admore-widgets-suite' ), 'grayscale' => __( 'Grayscale', 'admore-widgets-suite' ), 'dark' => __( 'Dark / Night', 'admore-widgets-suite' ), 'sepia' => __( 'Sepia / Vintage', 'admore-widgets-suite' ), ], 'separator' => 'before', ] ); $this->end_controls_section(); /* ── Additional Markers ── */ $this->start_controls_section( 'section_markers', [ 'label' => __( 'Additional Info Panel', 'admore-widgets-suite' ), 'condition' => [ 'embed_type!' => 'directions' ], ] ); $this->add_control( 'show_info_panel', [ 'label' => __( 'Show Info Panel', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => '', 'return_value' => 'yes', 'description' => __( 'Display a styled info card below or beside the map.', 'admore-widgets-suite' ), ] ); $this->add_control( 'info_title', [ 'label' => __( 'Title', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'Our Office', 'admore-widgets-suite' ), 'dynamic' => [ 'active' => true ], 'condition' => [ 'show_info_panel' => 'yes' ], ] ); $this->add_control( 'info_address', [ 'label' => __( 'Address Text', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXTAREA, 'default' => '', 'dynamic' => [ 'active' => true ], 'condition' => [ 'show_info_panel' => 'yes' ], ] ); $this->add_control( 'info_phone', [ 'label' => __( 'Phone', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', 'dynamic' => [ 'active' => true ], 'condition' => [ 'show_info_panel' => 'yes' ], ] ); $this->add_control( 'info_hours', [ 'label' => __( 'Hours', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', 'dynamic' => [ 'active' => true ], 'condition' => [ 'show_info_panel' => 'yes' ], ] ); $this->add_control( 'info_panel_position', [ 'label' => __( 'Panel Position', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'below', 'options' => [ 'below' => __( 'Below Map', 'admore-widgets-suite' ), 'right' => __( 'Right of Map', 'admore-widgets-suite' ), 'left' => __( 'Left of Map', 'admore-widgets-suite' ), ], 'condition' => [ 'show_info_panel' => 'yes' ], ] ); $this->end_controls_section(); /* ── Style ── */ $this->start_controls_section( 'section_style', [ 'label' => __( 'Map', 'admore-widgets-suite' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'map_height', [ 'label' => __( 'Height', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 100, 'max' => 1000 ] ], 'default' => [ 'size' => 400 ], 'selectors' => [ '{{WRAPPER}} .eppro-gm-frame' => 'height: {{SIZE}}px;' ], ] ); $this->add_control( 'border_radius', [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'max' => 40 ] ], 'default' => [ 'size' => 0 ], 'selectors' => [ '{{WRAPPER}} .eppro-gm-wrap, {{WRAPPER}} .eppro-gm-frame' => 'border-radius: {{SIZE}}px; overflow: hidden;' ], ] ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [ 'name' => 'map_shadow', 'selector' => '{{WRAPPER}} .eppro-gm-wrap', ] ); $this->end_controls_section(); } protected function render(): void { $s = $this->get_settings_for_display(); $type = $s['embed_type'] ?? 'place'; $key = sanitize_text_field( $s['api_key'] ?? '' ); $zoom = intval( $s['zoom']['size'] ?? 14 ); $lang = sanitize_text_field( $s['language'] ?? 'en' ); $mtype = $s['map_type'] ?? 'roadmap'; $scroll_disable = ! empty( $s['disable_scroll_zoom'] ) && 'yes' === $s['disable_scroll_zoom']; $map_style = $s['map_style'] ?? 'default'; $show_info = ! empty( $s['show_info_panel'] ) && 'yes' === $s['show_info_panel']; $info_pos = $s['info_panel_position'] ?? 'below'; $base = 'https://www.google.com/maps/embed/v1/'; if ( 'place' === $type ) { $addr = urlencode( $s['address'] ?? 'New York, NY, USA' ); $src = $base . 'place?q=' . $addr . '&zoom=' . $zoom . '&maptype=' . urlencode( $mtype ) . '&language=' . $lang; if ( $key ) $src .= '&key=' . urlencode( $key ); } elseif ( 'coordinates' === $type ) { $lat = floatval( $s['latitude'] ?? '40.7128' ); $lng = floatval( $s['longitude'] ?? '-74.0060' ); $src = $base . 'place?q=' . $lat . ',' . $lng . '&zoom=' . $zoom . '&maptype=' . urlencode( $mtype ) . '&language=' . $lang; if ( $key ) $src .= '&key=' . urlencode( $key ); } elseif ( 'directions' === $type ) { $orig = urlencode( $s['origin'] ?? '' ); $dest = urlencode( $s['destination'] ?? '' ); $src = $base . 'directions?origin=' . $orig . '&destination=' . $dest . '&language=' . $lang; if ( $key ) $src .= '&key=' . urlencode( $key ); } else { return; } if ( ! $key ) { $addr_fb = $s['address'] ?? 'New York, NY, USA'; $t_map = [ 'roadmap' => 'm', 'satellite' => 'k', 'hybrid' => 'h', 'terrain' => 'p' ]; $src = 'https://maps.google.com/maps?q=' . urlencode( $addr_fb ) . '&output=embed&z=' . $zoom . '&t=' . ( $t_map[ $mtype ] ?? 'm' ); } $style_filters = [ 'grayscale' => 'grayscale(100%)', 'dark' => 'invert(90%) hue-rotate(180deg)', 'sepia' => 'sepia(60%) contrast(0.9)', ]; $iframe_style = isset( $style_filters[ $map_style ] ) ? ' style="filter:' . esc_attr( $style_filters[ $map_style ] ) . ';"' : ''; $wrap_class = 'eppro-gm-wrap'; if ( $show_info && in_array( $info_pos, [ 'left', 'right' ], true ) ) { $wrap_class .= ' eppro-gm-wrap--' . esc_attr( $info_pos ); } ?>