• Resolved pinkarman

    (@pinkarman)


    Hello, in the previous version I inserted a custom map marker via wp filters following the instructions on Github, but after last update (ver. 1.3.0) the marker got back to the original one.

    This is the code I have added to functions.php

    add_filter('acf_osm_marker_html', function($html) {
        return '<div class="my-marker-inner">&times;</div>';
    });
    add_filter('acf_osm_marker_classname', function($html) {
        return 'my-marker';
    });

    Source

    Any clues?
    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter pinkarman

    (@pinkarman)

    I managed to “replace” the image only via CSS.
    For those who need:

    .leaflet-marker-icon {
       display: block;
      -moz-box-sizing: border-box;
      box-sizing: border-box;
      background: url(https://www.path.to/my/image.png) no-repeat;
    width: 28px !important;
    height: 40px !important;
    padding-left: 28px;
    background-size: contain;
    }

    you can use this filter :

    add_filter('acf_osm_marker_icon', function($icon) {
     $icon=array(
    	'iconUrl' => '/wp-content/themes/mytheme/img/marker-icon.png',
    	'iconRetinaUrl'	=> '/wp-content/themes/mytheme/img/[email protected]',
    	'iconSize' => [25, 41],
    	'iconAnchor' => [12, 41],
    	'popupAnchor'=> [1, -30],
    	'shadowUrl' => '/wp-content/plugins/acf-openstreetmap-field/assets/css/images/marker-shadow.png',
    	'shadowSize' => [41, 41],
     );
     return $icon;
    });

    see acf-openstreetmap-field/Core/Core.php line 99

    /**
       *	Return leaflet icon options.
       *
       *	@see https://leafletjs.com/reference-1.3.2.html#icon
       *
       *	@param $icon_options false (leaflet default icon or HTML icon) or array(
       *		'iconUrl'			=> image URL
       *		'iconRetinaUrl'		=> image URL
       *		'iconSize'			=> array( int, int )
       *		'iconAnchor'		=> array( int, int )
       *		'popupAnchor'		=> array( int, int )
       *		'tooltipAnchor'		=> array( int, int )
       *		'shadowUrl'			=> image URL
       *		'shadowRetinaUrl'	=> image URL
       *		'shadowSize'		=> array( int, int )
       *		'shadowAnchor'		=> array( int, int )
       *		'className'			=> string
       *	)
       */
      'icon'		=> apply_filters('acf_osm_marker_icon', false ),
    • This reply was modified 4 years, 2 months ago by zetoun17.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom marker in version 1.3.0?’ is closed to new replies.