Seenthis
•
 
Identifiants personnels
  • [mot de passe oublié ?]

 

cy_altern

@cy_altern
//
RSS: cy_altern
tous les messages de cy_altern
  • @cy_altern
    cy_altern @cy_altern CC BY-SA 6/04/2021
    2
    @spip
    @rastapopoulos
    2

    mapbox - Leaflet : How to add a text label to a custom marker icon ? - Stack Overflow
    ▻https://stackoverflow.com/questions/34775308/leaflet-how-to-add-a-text-label-to-a-custom-marker-icon

    Leaflet L.DivIcon feature that represents a lightweight icon for markers that uses a simple div element instead of an image

    une méthode pour afficher du texte sur les marqueurs Leaflet

    Voir aussi :
    – pour SPIP + GIS : ▻https://git.spip.net/spip-contrib-extensions/gis/src/branch/master/javascript/leaflet.gis.js#L249
    – ▻https://gis.stackexchange.com/questions/59571/how-to-add-text-only-labels-on-leaflet-map-with-no-icon
    – ▻https://leafletjs.com/reference-1.7.1.html#divicon

    #leaflet #GIS #SPIP #divicon #marqueur

    cy_altern @cy_altern CC BY-SA
    • @rastapopoulos
      RastaPopoulos @rastapopoulos CC BY-NC 6/04/2021

      et du coup en entre-deux pour l’instant j’ai fait ça :
      – activer les cluster + l’option singlemarker pour que même les points seuls utilisent le code des clusters (donc un divicon)
      – personnaliser la fonction qui génère les marqueurs divicon

      <script type="text/javascript">
      ;jQuery(function($) {       
              $('.carte_gis').on('load', function(){
                      this.map.options.clusterOptions.iconCreateFunction = function(cluster) {
                              var nb = 0;
                              $.each(cluster.getAllChildMarkers(), function(cle,valeur) {
                                      nb += valeur.feature.properties.nb_dossiers;
                              });
                             
                              return new L.DivIcon({ html: '<div><span>' + nb + '</span></div>', className: 'marker-cluster', iconSize: new L.Point(40, 40) });
                      }
              });
      });
      </script>
      RastaPopoulos @rastapopoulos CC BY-NC
    Écrire un commentaire

thèmes

  • #divicon
  • #GIS
  • #leaflet
  • #marqueur
  • #SPIP
À propos de Seenthis Propriété intellectuelle Recommandations API