How to use the leaflet.Util function in leaflet

To help you get started, we’ve selected a few leaflet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nextgis / nextgisweb_frontend / packages / leaflet-map-adapter / src / layer-adapters / ImageAdapter / ImageLayer.ts View on Github external
constructor(url: string, options: any) {
    super(options);
    this._url = url;

    // Move WMS parameters to params object
    const params: any = {};
    const opts: any = {};
    for (const opt in options) {
      if (opt in this.options) {
        opts[opt] = options[opt];
      } else {
        params[opt] = options[opt];
      }
    }
    L.Util.setOptions(this, opts);
    this.wmsParams = L.Util.extend({}, this.defaultWmsParams, params);
  }
github CartoDB / carto.js / src / geo / leaflet / leaflet-cartodb-layer-group-view.js View on Github external
}
      hovers[layer] = 0;
      if (!_.any(hovers)) {
        self.trigger('mouseout');
      }
      _featureOut && _featureOut.apply(this, arguments);
      self.featureOut && self.featureOut.apply(self, arguments);
    };

    opts.featureClick = _.debounce(function () {
      _featureClick && _featureClick.apply(self, arguments);
      self.featureClick && self.featureClick.apply(self, arguments);
    }, 10);

    // Set options
    L.Util.setOptions(this, opts);

    this.fire = this.trigger;

    // Bind changes to the urls of the model
    layerModel.bind('change:urls', function () {
      self.__update(function () {
        // if while the layer was processed in the server is removed
        // it should not be added to the map
        var id = L.stamp(self);
        if (!leafletMap._layers[id]) {
          return;
        }

        L.TileLayer.prototype.onAdd.call(self, leafletMap);
        self.fire('added');
        self.options.added = true;
github MephisTools / diablo2-live-viewer / src / diablo2-map.js View on Github external
const xy = function (x, y) {
  if (L.Util.isArray(x)) { // When doing xy([x, y]);
    return yx(x[1], x[0])
  }
  return yx(y, x) // When doing xy(x, y);
}
github DefinitelyTyped / DefinitelyTyped / types / leaflet / leaflet-tests.ts View on Github external
const extended1: typeof obj1 & typeof obj2 = L.Util.extend(obj1, obj2);
const extended2: typeof obj1 & typeof obj2 & typeof obj3 = L.Util.extend(obj1, obj2, obj3);
const extended3: typeof obj1 & typeof obj2 & typeof obj3 & typeof obj4 = L.Util.extend(obj1, obj2, obj3, obj4);
const extended4: typeof obj1 & typeof obj2 & typeof obj3 & typeof obj4 & typeof obj5 = L.Util.extend(obj1, obj2, obj3, obj4, obj5);

L.Util.create({});
L.Util.create(null, { foo: { writable: true, value: 'bar' } });

L.Util.bind(() => {}, {});
L.Util.stamp({});
L.Util.throttle(() => {}, 123, {});
L.Util.wrapNum(123, []);
L.Util.wrapNum(123, [], true);
L.Util.falseFn();
L.Util.formatNum(123);
L.Util.formatNum(123, 1);
L.Util.trim('word   ');
L.Util.splitWords('word word');
L.Util.setOptions({}, {});
L.Util.getParamString({});
L.Util.getParamString({}, '');
L.Util.getParamString({}, '', true);
L.Util.template('template', {});
L.Util.isArray({});
L.Util.indexOf([], {});
L.Util.requestAnimFrame(() => {});
L.Util.requestAnimFrame(timestamp => console.log(timestamp), {});
L.Util.requestAnimFrame(() => {}, {}, true);
L.Util.cancelAnimFrame(1);
L.Util.emptyImageUrl;

interface MyProperties {
github arg0navt / leaflet-react-track-player / src / laeflet-react-track-player / snake.js View on Github external
.multiplyBy(percent)
        .add(currPoint.multiplyBy(1 - percent));
      let headLatLng = this._map.containerPointToLatLng(headPoint);
      this._latlngs.push(headLatLng);
      if (this._latLngAnimation) {
        var i = Object.keys(this._eventParents);
        if (this._eventParents[i[0]]._options.progressFormat === "distance") {
          this._latLngAnimation(headLatLng, {
            n: this._snakingVertices,
            distance: this._snakingDistance + forward
          });
        } else this._latLngAnimation(headLatLng);
      }
      this.setLatLngs(this._latlngs);
      this.fire("snake");
      L.Util.requestAnimFrame(this._snakeRun, this);
    }
  },
github bbecquet / Leaflet.PolylineDecorator / src / L.PolylineDecorator.js View on Github external
initialize: function(paths, options) {
        L.FeatureGroup.prototype.initialize.call(this);
        L.Util.setOptions(this, options);
        this._map = null;
        this._paths = this._initPaths(paths);
        this._bounds = this._initBounds();
        this._patterns = this._initPatterns(this.options.patterns);
    },
github wladich / nakarte / src / lib / leaflet.control.layers.hotkeys / index.js View on Github external
_addItem: function(obj) {
                if (!L.Browser.touch || !L.Browser.mobile) {
                    obj = L.Util.extend({}, obj);
                    obj.name = extendLayerName(obj.name, obj.layer);
                }
                return originalAddItem.call(this, obj);
            },
github linghuam / Leaflet.TrackPlayBack / src / leaflet.trackplayback / clock.js View on Github external
_tick: function () {
    let now = +new Date()
    let fpstime = this._caculatefpsTime(now)
    let isPause = false
    let stepTime = fpstime * Math.pow(2, this._speed - 1)
    this._curTime += stepTime
    if (this._curTime >= this._endTime) {
      this._curTime = this._endTime
      isPause = true
    }
    this._trackController.drawTracksByTime(this._curTime)
    this.fire('tick', {
      time: this._curTime
    })
    if (!isPause) this._intervalID = L.Util.requestAnimFrame(this._tick, this)
  }
})
github SuperMap / iClient-JavaScript / src / leaflet / mapping / BaiduTileLayer.js View on Github external
getTileUrl: function (coords) {
        var url = L.Util.template(this.url, {
            num: Math.abs((coords.x + coords.y) % 8) + 1,
            x: coords.x,
            y: -coords.y - 1,
            z: this._getZoomForUrl(),
            styles: this.options.retina ? 'ph' : 'pl'
        });
        //支持代理
        if (this.options.tileProxy) {
            url = this.options.tileProxy + encodeURIComponent(url);
        }
        return url;
    }
});
github perliedman / leaflet-routing-machine / src / osrm.js View on Github external
initialize: function(options) {
			L.Util.setOptions(this, options);
			this._hints = {
				locations: {}
			};
		},