simplemap icon indicating copy to clipboard operation
simplemap copied to clipboard

Allow custom marker icon

Open tigerchick opened this issue 2 years ago • 3 comments

It would be helpful to easily allow custom marker icons. (ie. change the svg to one I specify) I hacked it for now by by adding the following to line 138 of ether/simplemap/src/services/EmbedService.php 'icon' => '/myPath/myMarker.svg',

tigerchick avatar Aug 04 '22 13:08 tigerchick

I'm really keen for this feature too. Any plans to get this functionality integrated?

joelzerner avatar Dec 17 '22 00:12 joelzerner

Hey, This is definitely something we want to add. Hopefully early in the new year. Thanks!

alexjcollins avatar Dec 18 '22 17:12 alexjcollins

At the moment, the cleanest way I found to do this is by looking through the code, I noticed that the ID of the map is also used as a global variable. Since I use OpenStreetMap and there's a method to update the icon programmatically through leaflet js, I do this:

{{
    craft.maps.embed({
        center: 'Hamburg, Germany',
        markers: mapLocations,
        width: '1800',
        height: '500',
        id: 'locations_map',
        options: {
            disableDefaultUI: true
        }
    })
}}
{% js %} 
    locations_map.whenReady(function() {
        let the_icon = L.icon({ 
            iconUrl: '/dist/icons/marker.svg',
            iconSize:     [80, 80],
            iconAnchor:   [40, 40]
        });
        for (let layerId in locations_map._layers) {
            let layer = locations_map._layers[layerId];
            if(layer instanceof L.Marker) {
                layer.setIcon(the_icon);
            }
        }
    });
{% endjs %} 

davidwebca avatar Feb 02 '23 22:02 davidwebca