• dwaber

    (@dwaber)


    Hi,

    How can I set a default color for my marker. I don’t need the nice blue one, but a red one for every purpose. Can I do that with a function and is there an example for that?

    Any help is very appreciated.
    Kind regards
    don

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor hupe13

    (@hupe13)

    The blue icon is the default of Leaflet. You can find markers in other colors e.g. at https://github.com/pointhi/leaflet-color-markers. Download these markers and use it like:
    [leaflet-marker lat=... lng=... iconUrl="/wp-content/uploads/icons/marker-icon-red.png" shadowUrl='/wp-content/uploads/icons/marker-shadow.png' iconAnchor='12,41' popupAnchor='1,-34']some text[/leaflet-marker].
    If you want more markers take a look: https://leafext.de/en/marker/extramarker/.

    Thread Starter dwaber

    (@dwaber)

    Thanks for your fast reply.

    Is there a way to set this as default marker. Or in other words: Can I overwrite the default shortcode with this options, that I can have always this new marker as default (apply a filter).

    Something like this:

    function my_default_marker( $marker ) {
    	$marker = array(
    		'shape'		=> 'square',
    		'color' 	=> 'green-light',
    		'icon'		=> 'fa-walking',
    		'iconColor' => 'white',
    	);
    
    	return $marker;
    }
    add_filter('leaflet_default_marker', 'my_default_marker', 10, 1);
    • This reply was modified 2 years ago by dwaber.
    • This reply was modified 2 years ago by dwaber.
    Plugin Contributor hupe13

    (@hupe13)

    Bozdoz has a FAQ: How Can I Add another Leaflet Plugin?. Look at the js part. I would start there.
    Or see how quick and dirty I did it with extramarker.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘marker color with shortcode’ is closed to new replies.