how to add a legend for the markers

Created on 29 July 2024, 6 months ago
Updated 15 August 2024, 5 months ago

Problem/Motivation

i am using leaflet views to display my map. is there a way to create a legend to explain the different markers. I want it to be on a block that i can put in the side bar.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Fixed

Version

10.2

Component

Documentation

Created by

🇺🇸United States dianacastillo Miami

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @dianacastillo
  • Status changed to Fixed 6 months ago
  • 🇮🇹Italy itamair

    Unlike the Geofield Map module that provides a dedicated plugin system for dynamic Theming Plugin System and Legend Block creation
    the Leaflet module doesn't provide all that ...

    But this doesn't look a kind of dramatic lack of functionality,
    because Leaflet module users can still take advantage of tokens and replacement patterns support in both Leaflet formatter and view style.
    With Leaflet the way I would go is the following:
    - Generate a specific Vocabulary with specific terms names and attached images, that would act as dynamic (token based) Leaflet Map markers images in the Leaflet formatter and/or view style;
    - Render a correspondant Legend generating a Block of the Vocabulary / Taxonomy terms that you are using for dynamic markers ...

    All simple like that ...

  • 🇩🇰Denmark ressa Copenhagen

    In the issue where I commented yesterday, you can see how I add a legend 💬 how to load faster or load a static image while loading map Active . In fact, all legends on arst.dk are inserted with that method, for example the latest for bird species per municipality: https://arst.dk/kort?data=fuglearter

    As opposed to the solution suggested by @itamair, it's not dynamically created, but a manually defined SVG-image.

    Another option would be to extract the values from the filter in the left side (under "FUGLEARTER"), and create it dynamically based on those values, but I just needed a quick solution, and it does the job.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024