Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom marker icon #359

Open
tigerchick opened this issue Aug 4, 2022 · 3 comments
Open

Allow custom marker icon #359

tigerchick opened this issue Aug 4, 2022 · 3 comments
Labels

Comments

@tigerchick
Copy link

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',

@joelzerner
Copy link

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

@alexjcollins
Copy link
Member

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

@davidwebca
Copy link
Contributor

davidwebca commented Feb 2, 2023

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 %} 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants