Plugin Directory

Changeset 3804102


Ignore:
Timestamp:
11/16/2026 02:12:41 AM (less than one hour ago)
Author:
intelchip
Message:

Release 1.5.0: add a Marker Size setting for the Default and Font Awesome markers

Location:
osm-map-elementor
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • osm-map-elementor/tags/1.5.0/assets/leaflet-fa-markers/L.Icon.FontAwesome.js

    r3107495 r3804102  
    2020
    2121        return div;
     22    },
     23
     24    // L.Icon's createShadow calls _createIcon, which this class overrides, so it would add a second pin
     25    createShadow: function () {
     26        return null;
    2227    },
    2328
    … …  
    5358        // container div
    5459        this.markerContainer = L.DomUtil.create("div", "leaflet-fa-markers");
     60
     61        // scale around the pin tip so the tip stays on the coordinate
     62        if (typeof options.markerScale === "number" && options.markerScale !== 1) {
     63            this.markerContainer.style.transform = `scale(${options.markerScale})`;
     64            this.markerContainer.style.transformOrigin = "16px 51px";
     65        }
    5566
    5667        // icon container div
  • osm-map-elementor/tags/1.5.0/constants.php

    r3804065 r3804102  
    66define('OSM_MAP_SLUG', 'osm-map-elementor');
    77define('OSM_PLUGIN_FOLDER', 'trunk' !== basename(__DIR__) ? basename(__DIR__) : OSM_MAP_SLUG);
    8 define('OSM_MAP_VERSION', '1.4.1');
     8define('OSM_MAP_VERSION', '1.5.0');
    99define('OSM_MAP_MIN_ELEMENTOR_VERSION', '3.30.0');
  • osm-map-elementor/tags/1.5.0/osm-map-elementor.php

    r3804065 r3804102  
    33 * Plugin Name:                OSM Map Widget for Elementor
    44 * Description:                A free Elementor Map Widget that Utilizes Open Street Map. Comes with features like adding multiple markers, and choosing from a library of custom tiles to change the look and feel.
    5  * Version:                    1.4.1
     5 * Version:                    1.5.0
    66 * Requires at least:          6.8
    77 * Requires PHP:               7.4
  • osm-map-elementor/tags/1.5.0/osm-map.php

    r3804065 r3804102  
    3232    public static $slug = OSM_MAP_SLUG;
    3333    public static $ver = OSM_MAP_VERSION;
     34
     35    private const OSM_MARKER_SIZE_MIN = 25;
     36    private const OSM_MARKER_SIZE_MAX = 200;
     37    // Mirrors L.Icon.Default in the vendored Leaflet; Test_Vendored_Marker_Geometry fails if they drift.
     38    private const OSM_DEFAULT_ICON_GEOMETRY = [
     39        'iconSize' => [25, 41],
     40        'iconAnchor' => [12, 41],
     41        'popupAnchor' => [1, -34],
     42        'tooltipAnchor' => [16, -28],
     43        'shadowSize' => [41, 41],
     44    ];
     45    private const OSM_FA_MARKER_TOP = -50;
    3446
    3547    /**
    … …  
    621633
    622634        $this->add_control(
     635            'marker_size',
     636            [
     637                'label' => __('Marker Size', 'osm-map-elementor'),
     638                'type' => Controls_Manager::SLIDER,
     639                'size_units' => ['%'],
     640                'range' => [
     641                    '%' => [
     642                        'min' => self::OSM_MARKER_SIZE_MIN,
     643                        'max' => self::OSM_MARKER_SIZE_MAX,
     644                        'step' => 5,
     645                    ],
     646                ],
     647                'default' => [
     648                    'unit' => '%',
     649                    'size' => 100,
     650                ],
     651                'description' => __('Scales the whole marker, including its icon and where its popup or tooltip opens.', 'osm-map-elementor'),
     652                'condition' => [
     653                    'icon_type' => ['', 'fontawesome'],
     654                ],
     655            ]
     656        );
     657
     658        $this->add_control(
    623659            'fontawesome_icon',
    624660            [
    … …  
    16991735                <?php
    17001736                $icon_type = !empty($settings['icon_type']) ? $settings['icon_type'] : null;
     1737                $marker_scale = $this->osm_marker_scale($settings['marker_size'] ?? null);
    17011738                switch ($icon_type):
    17021739                case 'fontawesome':
    … …  
    17281765                    $fa_icon_options['iconYOffset'] = $icon_offset['yOffset'];
    17291766                }
     1767
     1768                if (1.0 !== $marker_scale) {
     1769                    $fa_icon_options['markerScale'] = $marker_scale;
     1770                    $fa_icon_options['popupAnchor'] = self::osm_scale_point([0, self::OSM_FA_MARKER_TOP], $marker_scale);
     1771                }
     1772                $fa_tooltip_offset = self::osm_scale_point([0, self::OSM_FA_MARKER_TOP], $marker_scale);
    17301773                ?>
    17311774
    1732                 markerOptions.icon = L.icon.fontAwesome(<?php echo wp_json_encode($fa_icon_options); ?>);
     1775                const markerIconOptions = <?php echo wp_json_encode($fa_icon_options); ?>;
     1776                const markerTooltipOffset = <?php echo wp_json_encode($fa_tooltip_offset); ?>;
     1777                markerOptions.icon = L.icon.fontAwesome(markerIconOptions);
    17331778                <?php
    17341779                break;
    … …  
    17931838                markerOptions.icon = markerIcon;
    17941839                <?php endif; ?>
     1840                <?php
     1841                break;
     1842                default:
     1843                if (1.0 !== $marker_scale):
     1844                    $default_icon_options = array_map(function ($point) use ($marker_scale) {
     1845                        return self::osm_scale_point($point, $marker_scale);
     1846                    }, self::OSM_DEFAULT_ICON_GEOMETRY);
     1847                    // L.Icon.Default only picks the 2x image on retina screens and prefixes this file name with its image path
     1848                    if ($marker_scale > 1.0) {
     1849                        $default_icon_options['iconUrl'] = 'marker-icon-2x.png';
     1850                    }
     1851                ?>
     1852                const markerIconOptions = <?php echo wp_json_encode($default_icon_options); ?>;
     1853                markerOptions.icon = new L.Icon.Default(markerIconOptions);
     1854                <?php endif; ?>
    17951855                <?php endswitch; ?>
    17961856
    … …  
    18761936                                    // update offset for fontawesome markers
    18771937                                    tooltipOptions.direction = "top";
    1878                                     tooltipOptions.offset = [0, -50];
     1938                                    tooltipOptions.offset = markerTooltipOffset;
    18791939                                <?php  endif; ?>
    18801940
    … …  
    20112071
    20122072    /**
     2073     * @param mixed $setting Elementor slider value.
     2074     */
     2075    private function osm_marker_scale($setting): float
     2076    {
     2077        if (!is_array($setting) || !isset($setting['size']) || !is_numeric($setting['size'])) {
     2078            return 1.0;
     2079        }
     2080
     2081        $percent = max(self::OSM_MARKER_SIZE_MIN, min(self::OSM_MARKER_SIZE_MAX, (float) $setting['size']));
     2082
     2083        return $percent / 100;
     2084    }
     2085
     2086    /**
     2087     * @param int[] $point
     2088     * @return int[]
     2089     */
     2090    private static function osm_scale_point(array $point, float $scale): array
     2091    {
     2092        return [(int) round($point[0] * $scale), (int) round($point[1] * $scale)];
     2093    }
     2094
     2095    /**
    20132096     * Parses a "lat,lng" string into floats, rejecting malformed or out-of-range values.
    20142097     *
  • osm-map-elementor/tags/1.5.0/readme.txt

    r3804065 r3804102  
    11=== OSM Map Widget for Elementor ===
    22Plugin Name: OSM Map Widget for Elementor
    3 Version: 1.4.1
     3Version: 1.5.0
    44Author: Plugin Contributors
    55Author URI: https://github.com/flopperj/osm-map-elementor/graphs/contributors
    … …  
    99Tested up to: 7.1
    1010Requires PHP: 7.4
    11 Stable tag: 1.4.1
     11Stable tag: 1.5.0
    1212License: GPLv3
    1313License URI: https://www.gnu.org/licenses/gpl-3.0.html
    … …  
    6565
    6666== Changelog ==
     67= 1.5.0 =
     68* NEW: Marker Size setting for the Default and Font Awesome marker icons. It scales the whole marker from 25% to 200%, and popups and tooltips follow the new size. Existing maps keep their current marker size. The Font Awesome Icon Size setting now scales together with the pin. Thanks to @xanhcloud24.
     69
    6770= 1.4.1 =
    6871* IMPROVEMENT: Links that open in a new tab, such as map attributions and settings page links, now use rel="noopener noreferrer". The marker button uses rel="noopener" when it opens a new tab. Thanks to @frapsd.
    … …  
    98101
    99102== Upgrade Notice ==
     103= 1.5.0 =
     104Adds a Marker Size setting for the Default and Font Awesome markers.
     105
    100106= 1.4.1 =
    101107Links that open in a new tab now use rel="noopener".
  • osm-map-elementor/trunk/assets/leaflet-fa-markers/L.Icon.FontAwesome.js

    r3107495 r3804102  
    2020
    2121        return div;
     22    },
     23
     24    // L.Icon's createShadow calls _createIcon, which this class overrides, so it would add a second pin
     25    createShadow: function () {
     26        return null;
    2227    },
    2328
    … …  
    5358        // container div
    5459        this.markerContainer = L.DomUtil.create("div", "leaflet-fa-markers");
     60
     61        // scale around the pin tip so the tip stays on the coordinate
     62        if (typeof options.markerScale === "number" && options.markerScale !== 1) {
     63            this.markerContainer.style.transform = `scale(${options.markerScale})`;
     64            this.markerContainer.style.transformOrigin = "16px 51px";
     65        }
    5566
    5667        // icon container div
  • osm-map-elementor/trunk/constants.php

    r3804065 r3804102  
    66define('OSM_MAP_SLUG', 'osm-map-elementor');
    77define('OSM_PLUGIN_FOLDER', 'trunk' !== basename(__DIR__) ? basename(__DIR__) : OSM_MAP_SLUG);
    8 define('OSM_MAP_VERSION', '1.4.1');
     8define('OSM_MAP_VERSION', '1.5.0');
    99define('OSM_MAP_MIN_ELEMENTOR_VERSION', '3.30.0');
  • osm-map-elementor/trunk/osm-map-elementor.php

    r3804065 r3804102  
    33 * Plugin Name:                OSM Map Widget for Elementor
    44 * Description:                A free Elementor Map Widget that Utilizes Open Street Map. Comes with features like adding multiple markers, and choosing from a library of custom tiles to change the look and feel.
    5  * Version:                    1.4.1
     5 * Version:                    1.5.0
    66 * Requires at least:          6.8
    77 * Requires PHP:               7.4
  • osm-map-elementor/trunk/osm-map.php

    r3804065 r3804102  
    3232    public static $slug = OSM_MAP_SLUG;
    3333    public static $ver = OSM_MAP_VERSION;
     34
     35    private const OSM_MARKER_SIZE_MIN = 25;
     36    private const OSM_MARKER_SIZE_MAX = 200;
     37    // Mirrors L.Icon.Default in the vendored Leaflet; Test_Vendored_Marker_Geometry fails if they drift.
     38    private const OSM_DEFAULT_ICON_GEOMETRY = [
     39        'iconSize' => [25, 41],
     40        'iconAnchor' => [12, 41],
     41        'popupAnchor' => [1, -34],
     42        'tooltipAnchor' => [16, -28],
     43        'shadowSize' => [41, 41],
     44    ];
     45    private const OSM_FA_MARKER_TOP = -50;
    3446
    3547    /**
    … …  
    621633
    622634        $this->add_control(
     635            'marker_size',
     636            [
     637                'label' => __('Marker Size', 'osm-map-elementor'),
     638                'type' => Controls_Manager::SLIDER,
     639                'size_units' => ['%'],
     640                'range' => [
     641                    '%' => [
     642                        'min' => self::OSM_MARKER_SIZE_MIN,
     643                        'max' => self::OSM_MARKER_SIZE_MAX,
     644                        'step' => 5,
     645                    ],
     646                ],
     647                'default' => [
     648                    'unit' => '%',
     649                    'size' => 100,
     650                ],
     651                'description' => __('Scales the whole marker, including its icon and where its popup or tooltip opens.', 'osm-map-elementor'),
     652                'condition' => [
     653                    'icon_type' => ['', 'fontawesome'],
     654                ],
     655            ]
     656        );
     657
     658        $this->add_control(
    623659            'fontawesome_icon',
    624660            [
    … …  
    16991735                <?php
    17001736                $icon_type = !empty($settings['icon_type']) ? $settings['icon_type'] : null;
     1737                $marker_scale = $this->osm_marker_scale($settings['marker_size'] ?? null);
    17011738                switch ($icon_type):
    17021739                case 'fontawesome':
    … …  
    17281765                    $fa_icon_options['iconYOffset'] = $icon_offset['yOffset'];
    17291766                }
     1767
     1768                if (1.0 !== $marker_scale) {
     1769                    $fa_icon_options['markerScale'] = $marker_scale;
     1770                    $fa_icon_options['popupAnchor'] = self::osm_scale_point([0, self::OSM_FA_MARKER_TOP], $marker_scale);
     1771                }
     1772                $fa_tooltip_offset = self::osm_scale_point([0, self::OSM_FA_MARKER_TOP], $marker_scale);
    17301773                ?>
    17311774
    1732                 markerOptions.icon = L.icon.fontAwesome(<?php echo wp_json_encode($fa_icon_options); ?>);
     1775                const markerIconOptions = <?php echo wp_json_encode($fa_icon_options); ?>;
     1776                const markerTooltipOffset = <?php echo wp_json_encode($fa_tooltip_offset); ?>;
     1777                markerOptions.icon = L.icon.fontAwesome(markerIconOptions);
    17331778                <?php
    17341779                break;
    … …  
    17931838                markerOptions.icon = markerIcon;
    17941839                <?php endif; ?>
     1840                <?php
     1841                break;
     1842                default:
     1843                if (1.0 !== $marker_scale):
     1844                    $default_icon_options = array_map(function ($point) use ($marker_scale) {
     1845                        return self::osm_scale_point($point, $marker_scale);
     1846                    }, self::OSM_DEFAULT_ICON_GEOMETRY);
     1847                    // L.Icon.Default only picks the 2x image on retina screens and prefixes this file name with its image path
     1848                    if ($marker_scale > 1.0) {
     1849                        $default_icon_options['iconUrl'] = 'marker-icon-2x.png';
     1850                    }
     1851                ?>
     1852                const markerIconOptions = <?php echo wp_json_encode($default_icon_options); ?>;
     1853                markerOptions.icon = new L.Icon.Default(markerIconOptions);
     1854                <?php endif; ?>
    17951855                <?php endswitch; ?>
    17961856
    … …  
    18761936                                    // update offset for fontawesome markers
    18771937                                    tooltipOptions.direction = "top";
    1878                                     tooltipOptions.offset = [0, -50];
     1938                                    tooltipOptions.offset = markerTooltipOffset;
    18791939                                <?php  endif; ?>
    18801940
    … …  
    20112071
    20122072    /**
     2073     * @param mixed $setting Elementor slider value.
     2074     */
     2075    private function osm_marker_scale($setting): float
     2076    {
     2077        if (!is_array($setting) || !isset($setting['size']) || !is_numeric($setting['size'])) {
     2078            return 1.0;
     2079        }
     2080
     2081        $percent = max(self::OSM_MARKER_SIZE_MIN, min(self::OSM_MARKER_SIZE_MAX, (float) $setting['size']));
     2082
     2083        return $percent / 100;
     2084    }
     2085
     2086    /**
     2087     * @param int[] $point
     2088     * @return int[]
     2089     */
     2090    private static function osm_scale_point(array $point, float $scale): array
     2091    {
     2092        return [(int) round($point[0] * $scale), (int) round($point[1] * $scale)];
     2093    }
     2094
     2095    /**
    20132096     * Parses a "lat,lng" string into floats, rejecting malformed or out-of-range values.
    20142097     *
  • osm-map-elementor/trunk/readme.txt

    r3804065 r3804102  
    11=== OSM Map Widget for Elementor ===
    22Plugin Name: OSM Map Widget for Elementor
    3 Version: 1.4.1
     3Version: 1.5.0
    44Author: Plugin Contributors
    55Author URI: https://github.com/flopperj/osm-map-elementor/graphs/contributors
    … …  
    99Tested up to: 7.1
    1010Requires PHP: 7.4
    11 Stable tag: 1.4.1
     11Stable tag: 1.5.0
    1212License: GPLv3
    1313License URI: https://www.gnu.org/licenses/gpl-3.0.html
    … …  
    6565
    6666== Changelog ==
     67= 1.5.0 =
     68* NEW: Marker Size setting for the Default and Font Awesome marker icons. It scales the whole marker from 25% to 200%, and popups and tooltips follow the new size. Existing maps keep their current marker size. The Font Awesome Icon Size setting now scales together with the pin. Thanks to @xanhcloud24.
     69
    6770= 1.4.1 =
    6871* IMPROVEMENT: Links that open in a new tab, such as map attributions and settings page links, now use rel="noopener noreferrer". The marker button uses rel="noopener" when it opens a new tab. Thanks to @frapsd.
    … …  
    98101
    99102== Upgrade Notice ==
     103= 1.5.0 =
     104Adds a Marker Size setting for the Default and Font Awesome markers.
     105
    100106= 1.4.1 =
    101107Links that open in a new tab now use rel="noopener".
Note: See TracChangeset for help on using the changeset viewer.