humangeo / leaflet-dvf

Leaflet Data Visualization Framework
MIT License
689 stars 153 forks source link

a little mistake about the "_createText" method in the source code #128

Open xiallyspider opened 6 years ago

xiallyspider commented 6 years ago

v0.3.1 ->leaflet-dvf.js

   _createText: function (layer) {
        // var options = layer.options.text || {};
        var options = layer.options || {};
       ......
        var textNode = document.createTextNode(options.text);
       ......
     }
sfairgrieve commented 6 years ago

Thanks for pointing this out, and apologies for the confusion. The source code is actually the intended behavior. The layer text option tells the code that you want to display text on the SVG element and provides configuration options for that text element that will be displayed. One parameter is text, which is the actual text to be displayed, but you can also provide a path option that tells the browser to display the text along a path (if the element is a line or polygon) or provide more advanced styling options or override specific SVG text element attributes for the SVG text element that gets created. For example:

var thing = new L.<object>(<geometry>, {
   text: {
      text: 'Test',
      attr: {
         // Keys/values for SVG text element attributes to specify explicitly
      },
      style: {
         'fill':  '#123',
         'stroke': '#fff'
      },
      path: {
          startOffset: '65%'
      }
   }
}

Does that make sense?

xiallyspider commented 6 years ago

Opps, It seems that I did not look carefully enough,sorry for it and appreciate your patience.Now I know how to use it

valerio-bozzolan commented 2 years ago

@xiallyspider can you please mark as resolved? :)