humangeo / leaflet-dvf

Leaflet Data Visualization Framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

xiallyspider opened this issue · comments

v0.3.1 ->leaflet-dvf.js

   _createText: function (layer) {
        // var options = layer.options.text || {};
        var options = layer.options || {};
       ......
        var textNode = document.createTextNode(options.text);
       ......
     }

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?

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

@xiallyspider can you please mark as resolved? :)