How to use the leaflet.extend 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 nextzen / nextzen.js / src / js / components / mapControl.js View on Github external
L.Map.prototype.initialize.call(this, element, opts);

    this._checkDeprecatedKey();

    if (this.options._useTangram) {
      var tangramOptions = opts.tangramOptions || {};

      // debugTangram is deprecated; remove in v1.0
      if (this.options.debugTangram) {
        // tangramOptions = L.extend({}, tangramOptions, {debug: true});
        console.warn('Mapzen.js warning: `options.debugTangram` is deprecated.');
      }

      // As of v1.0, scene will need to be part of tangramOptions
      if (this.options.scene) {
        tangramOptions = L.extend({}, tangramOptions, {scene: this.options.scene});
        console.warn('Mapzen.js warning: `options.scene` is deprecated and will be removed in v1.0. Please use `options.tangramOptions.scene`.');
      }

      this._tangram = L.Nextzen._tangram(tangramOptions);
      this._tangramLayer = this._tangram.addTo(this);

      // tangramloaded event is deprecated; remove in v1.0
      var self = this;
      self._tangram.on('loaded', function (e) {
        self.fire('tangramloaded', {
          tangramLayer: e.layer,
          tangramVersion: e.version
        });
      });
    }
github nasa / earthdata-search / static / src / js / containers / SpatialSelectionContainer / SpatialSelectionContainer.js View on Github external
renderBoundingBox(rectangle, map) {
    if (map) {
      const shape = rectangle
      // southwest longitude should not be greater than northeast
      if (shape[0].lng > shape[1].lng) {
        shape[1].lng += 360
      }

      const bounds = new L.LatLngBounds(...Array.from(shape || []))
      const options = L.extend({}, L.Draw.Rectangle.prototype.options.shapeOptions, this._colorOptions)
      const rect = new L.Rectangle(bounds, options)

      rect.addTo(map)
      map.panTo(L.latLngBounds(rect.getLatLngs()).getCenter())
      this.setState({ drawnLayer: rect })
    }
  }
github Project-OSRM / osrm-frontend / src / index.js View on Github external
var L = require('leaflet');
var Geocoder = require('leaflet-control-geocoder');
var LRM = require('leaflet-routing-machine');
var locate = require('leaflet.locatecontrol');
var options = require('./lrm_options');
var links = require('./links');
var leafletOptions = require('./leaflet_options');
var ls = require('local-storage');
var tools = require('./tools');
var state = require('./state');
var localization = require('./localization');
require('./polyfill');

var parsedOptions = links.parse(window.location.search.slice(1));
var mergedOptions = L.extend(leafletOptions.defaultState, parsedOptions);
var local = localization.get(mergedOptions.language);

// load only after language was chosen
var itineraryBuilder = require('./itinerary_builder')(mergedOptions.language);

var mapLayer = leafletOptions.layer;
var overlay = leafletOptions.overlay;
var baselayer = ls.get('layer') ? mapLayer[0][ls.get('layer')] : mapLayer[0]['Mapbox Streets'];
var layers = ls.get('getOverlay') && [baselayer, overlay['Small Components']] || baselayer;
var map = L.map('map', {
  zoomControl: true,
  dragging: true,
  layers: layers,
  maxZoom: 18
}).setView(mergedOptions.center, mergedOptions.zoom);
github wladich / nakarte / src / lib / leaflet.layer.canvasMarkers / index.js View on Github external
onClick: function(e) {
            if (this._map.clickLocked) {
                return;
            }
            const marker = this.findMarkerFromMouseEvent(e);
            if (marker) {
                L.extend(e, {marker: marker});
                this.fire('markerclick', e);
            }
        },
github wq / wq.app / packages / map / src / locate.js View on Github external
locate.init = function(conf) {
    L.extend(locate.config, conf || {});
};
github sozialhelden / wheelmap-frontend / src / components / Map / GeoJSONTileLayer.js View on Github external
r: L.Browser.retina ? '@2x' : '',
      s: this._getSubdomain(coords),
      x: coords.x,
      y: coords.y,
      z: this._getZoomForUrl(),
    };
    data.bbox = geoTileToBbox(data);
    if (this._map && !this._map.options.crs.infinite) {
      const invertedY = this._globalTileRange.max.y - coords.y;
      if (this.options.tms) {
        data.y = invertedY;
      }
      data['-y'] = invertedY;
    }

    return L.Util.template(this._url, L.extend(data, this.options));
  }
github Labelbox / Labelbox / templates / image-segmentation-ts / src / labeling-screen / leaflet-draw / leaflet.draw.tsx View on Github external
initialize: function(t) {
        t.edit && (void 0 === t.edit.selectedPathOptions && (t.edit.selectedPathOptions = this.options.edit.selectedPathOptions), t.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, t.edit.selectedPathOptions)), t.remove && (t.remove = L.extend({}, this.options.remove, t.remove)), t.poly && (t.poly = L.extend({}, this.options.poly, t.poly)), this._toolbarClass = "leaflet-draw-edit", L.Toolbar.prototype.initialize.call(this, t), this._selectedFeatureCount = 0
      },
      getModeHandlers: function(t) {
github hackoregon / civic / packages / housing / src / externals / leafletPattern.js View on Github external
setShape: function(shape) {
      this.options = L.extend({}, this.options, shape);
      this._updateShape();
    },
  });
github nasa / earthdata-search / static / src / js / components / SpatialSelection / SpatialSelection.js View on Github external
renderPolygon(polygon, featureGroup) {
    if (featureGroup) {
      const options = L.extend(
        {},
        L.Draw.Polygon.prototype.options.shapeOptions,
        colorOptions
      )
      const poly = new L.SphericalPolygon(polygon, options)

      poly.type = 'polygon'
      poly.addTo(featureGroup)

      this.setState({
        drawnLayer: poly,
        drawnLayerType: 'polygon'
      })
      this.setLayer(poly)
    }
  }
github Labelbox / Labelbox / templates / image-segmentation / src / labeling-screen / leaflet-draw / leaflet.draw.js View on Github external
initialize: function(t) {
        t.edit && (void 0 === t.edit.selectedPathOptions && (t.edit.selectedPathOptions = this.options.edit.selectedPathOptions), t.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, t.edit.selectedPathOptions)), t.remove && (t.remove = L.extend({}, this.options.remove, t.remove)), t.poly && (t.poly = L.extend({}, this.options.poly, t.poly)), this._toolbarClass = "leaflet-draw-edit", L.Toolbar.prototype.initialize.call(this, t), this._selectedFeatureCount = 0
      },
      getModeHandlers: function(t) {