-
-
Notifications
You must be signed in to change notification settings - Fork 356
[UX Map] Allow to customize the marker icon #2109
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
Comments
I came here to make this issue 😀. |
Why not offering a plug-and-play set of markers / color palette ? My feeling is this is typically the kind of small things that offer great DX in the end (simple solutions for standard needs) (not exclusive with the image url idea of course) |
So i played a bit with both providers... so there is plenty of things we can do (for both) 1 - Image URLnew Icon(url: 'https://example.com/my-image.png', /* other options ... */ ) 2 - Asset URLBut users will probably need to use "local" assets, so i suggest we accept the logical path of the file (exactly like the Something like new Icon(asset: '/images/icons/my-image.png', /* ... */ );
// will be transformed in a full (versionned) url:
// --> /assets/images/icons/my-image-sdf87.png Or we could state that if you pass a relative / root relative url, it is an asset ? new Icon(url: '/images/icons/my-image.png' /* = this url is an asset URL ? */ ) 3 - SVG/HTML contentThen, both accept SVG and/or HTML in some form. This would allow very custom code directly in the template next to the map.. but i think i will probably have less value via PHP construction. <div id="super-red-marker">
{# image, svg, custom classes... #}
</div>
{{ ux_map({
markers: [
{ lat: ..., lng: ..., icon: { selector: '#super-red-marker' } }
]
)} 4 - UX Icon integration 🥳The coolest thing to me would be to integrate the UX Icon component, offering the same amazing DX new Icon(name: 'bi:marker-solid' /* ... */ ) {{ ux_map({
markers: [
{ lat: ..., lng: ..., icon: { name: 'bi-marker-solid', color: '#4b57e' } }
]
)} I'd love to get your feedback on all this :) (cc @Kocal ) |
@BrentRobert @javiereguiluz any direction / suggestion / preference regarding DX ? |
@smnandre I like a lot your proposal in #2109 (comment) I don't really have additional comments or suggestions. I like it all. Thanks! |
@smnandre I will take a look today of what you proposed! |
All 4 options look good to me. |
I like your proposals @smnandre, they are simple to use and I believe they can resolve 80% of people use cases. Do we only want to support When I used Google Maps on my website (before UX Map), I used glyph to customise the marker content, it's a specific feature that doesn't exist with Leaflet AFAIK: with the following code: const pinElement = new PinElement({,
glyph: new URL(place.iconMaskUri), // https://example.com/glyph-cinema.svg
glyphColor: "white",
});
const marker = new AdvancedMarkerElement({
map,
content: pinElement.element, // magic happens here
position: new google.maps.LatLng(...),
}); We agree we don't want to natively support this, right? :) |
I think we should (at least what will be used in all providers: size, offset, etc).. let's work on the simpliest DX possible for basic case that yet allow advanced users. And think both map created fully in PHP or in template directly :) So how do you see it @Kocal ? A simple step 1 to start, and then other ones ? |
I think we can go for 1 and 2, then 3, and finally 4, wdyt? |
Yes, and i think we should move on first (or in the same time) on the Twig function... because assets will often be used directly from Twig. When you have time (nothing urgent here 😅 ) ... can have a look at my answers on the other PR ? |
Will be released in 2.24 |
These days I'm moving a custom-made Leaflet map to UX Maps. So far everything is great. But I'm missing the option to customize the marker icon.
I know it's possible with a custom Stimulus controller. But, don't you think that this is a common enough feature? If you agree, we could add a new
Icon
class to configure theMarker
icon.This is the real JS code that I was using in the map, to show which attributes could be useful:
The text was updated successfully, but these errors were encountered: