我正在编写一个扩展折线功能的Leaflet插件。在我的插件中,我正在使用SVGPathSegList接口访问路径段。但是根据Chrome DevTools的说明,该接口将在Chrome 48中删除。我正在寻找另一种访问路径段的可能性。这是我的小提琴。(function () { var __onAdd = L.Polyline.prototype.onAdd, __onRemove = L.Polyline.prototype.onRemove, __updatePath = L.Polyline.prototype._updatePath, __bringToFront = L.Polyline.prototype.bringToFront; L.Polyline.include({ onAdd: function (map) { __onAdd.call(this, map); this._textRedraw(); }, onRemove: function (map) { __onRemove.call(this, map); }, bringToFront: function () { __bringToFront.call(this); this._textRedraw(); }, _textRedraw: function () { var textNodes = this._path.parentElement.getElementsByTagName('text'), tnIndex; if (textNodes.length > 0) { for (tnIndex = textNodes.length - 1; tnIndex >= 0; tnIndex -= 1) { textNodes[tnIndex].parentNode.removeChild(textNodes[tnIndex]); } } if (this.options.measurements) { this.setText(); } }, setText: function () { var path = this._path, points = this.getLatLngs(), pathSeg, prevPathSeg, center, angle, rotation, textNode; /* * If not in SVG mode or Polyline not added to map yet return * setText will be called by onAdd, using value stored in this._text */ if (!L.Browser.svg || typeof this._map === 'undefined') { return this; }
添加回答
举报
0/150
提交
取消