maplibre / maplibre-style-spec

MapLibre Style Specification & Utilities
https://maplibre.org/maplibre-style-spec/
Other
70 stars 59 forks source link

Design proposal: Layer type square (and maybe other shapes) #116

Open BezBIS opened 2 years ago

BezBIS commented 2 years ago

Motivation

I'm new to maplibre so could well be missing something, but can't see this as an option in the documentation.

I'm trying to render a map where we have records with different levels of precision. The existing soluton shows high precision records as a circle and lower precision records as a larger sqaure. It would be really nice to be able to specify a square or rectangle as the layer type in the same way as you can currently use circle.

I have no idea what the technical implementation of this would look like, but hope it would not bee too complicatd as it's still a simple plolygon.

Design Alternatives

Do nothing.

Implementation

Something like this:

map.addLayer({
            id: 'points',
            type: 'rectangle',
            source: 'points',
            paint: {
                'rectangle-color': #e00,
                'rectangle-width': 12,
                'rectangle-height': 12,
                'rectangle-stroke-width': 1,
                'rectangle-stroke-color': '#000'
            }
        });
HarelM commented 2 years ago

You can use sdf icons in theory, but if we add something like that I would recommend a rectangle with rounded corners to facilitate a lot more shapes...

BezBIS commented 2 years ago

You can use sdf icons in theory, but if we add something like that I would recommend a rectangle with rounded corners to facilitate a lot more shapes...

A rounded rectnagle would be really useful. I'm not sure how many other people would benefit from something like this though, it could well be rather niche.

HarelM commented 2 years ago

You also might be able to pull this off by using a custom layer...?

wadclapp commented 1 year ago

I'm also looking for this feature, also don't know how complicated it would be to implement.

Desirably I'd like to be able to use an n-sided polygon as the background of a marker instead of a circle (triangle/square/pentagon), and possibly more, such as a star-shape. I have a lot of bg-colour/icon combos, which are also dynamic, so it isn't practical to add them all in the image sprite.

I achieved this originally as HTML markers, but I have too many markers now where it's no longer a performant way to achieve it.

HarelM commented 1 year ago

I've moved this to the style-spec repo for further discussion.

xabbu42 commented 1 month ago

We would also benefit from this. Our use-case are user generated drawings on a map saved as a geojson with meta information. if maplibre-gl-js would support all shapes we offer, we could display these drawings just using a normal style.

HarelM commented 1 month ago

What's the CSS equivalent to this?

loremru commented 2 days ago

any updates?