this._regionsLayer.getLayers().forEach(function(f) {
            f.setStyle({
                opacity: 0.3
            });

            L.DomEvent.addListener(f, 'mouseover', function(e) {
                if(this._activeFilters.indexOf(this._regionsLayer.getLayerId(e.target)) < 0) {
                    e.target.setStyle({
                        opacity: 0.5
                    });
                }
            }, this);

            L.DomEvent.addListener(f, 'mouseout', function(e) {
                if(this._activeFilters.indexOf(this._regionsLayer.getLayerId(e.target)) < 0) {
                    e.target.setStyle({
                        opacity: 0.3
                    });
                }
            }, this);

            L.DomEvent.addListener(f, 'click', this._onFeatureClick, this);

            var key = this._getFeatureId(f);
            if (!this._filters[key]) {
                this._numItems++;
                this._filters[key] = this._addItem(f);
            }
        }, this);
function setupTimeline(viewModel) {
    var timelineContainer = document.getElementsByClassName('animation-timeline')[0];
    var controlsContainer = document.getElementsByClassName('animation-controls')[0];

    L.DomEvent.disableClickPropagation(timelineContainer);
    L.DomEvent.disableClickPropagation(controlsContainer);


    var timeline = new Timeline(timelineContainer, viewModel.terria.clock);
    viewModel.timeline = timeline;

    timeline.makeLabel = function(time) {

        var totalDays = JulianDate.daysDifference(viewModel.terria.clock.stopTime, viewModel.terria.clock.startTime);

        if (totalDays > 14) {
            return formatDate(JulianDate.toDate(time), viewModel.locale);
        }
        else if (totalDays < 1) {
            return formatTime(JulianDate.toDate(time), viewModel.locale);
        }
        return formatDateTime(JulianDate.toDate(time), viewModel.locale);
    };

    timeline.scrubFunction = function(e) {
        var clock = e.clock;
        clock.currentTime = e.timeJulian;
        clock.shouldAnimate = false;
        viewModel.isPlaying = false;
        viewModel.terria.currentViewer.notifyRepaintRequired();
    };

    timeline.addEventListener('settime', timeline.scrubFunction, false);
}
    _initLayout: function () {
        var class_name = 'leaflet-control-filter',
            container = this._container = L.DomUtil.create('div', class_name);

        if (!L.Browser.touch) {
            L.DomEvent.disableClickPropagation(container);
            L.DomEvent.on(container, 'mousewheel', L.DomEvent.stopPropagation);
        } else {
            L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation);
        }

        var form = this._form = L.DomUtil.create('form', class_name + '-list');
        var locationFieldset = this._locationFieldset = L.DomUtil.create('fieldset', class_name + '-fieldset');
        var distanceFieldset = this._distanceFieldset = L.DomUtil.create('fieldset', class_name + '-fieldset');

        var locationFieldsetLegend = L.DomUtil.create('legend', class_name + '-fieldset-legend', locationFieldset);
        locationFieldsetLegend.innerHTML = this.options.options.strings.location;

        var distanceFieldsetLegend = L.DomUtil.create('legend', class_name + '-fieldset-legend', distanceFieldset);
        distanceFieldsetLegend.innerHTML = this.options.options.strings.distance;

        form.appendChild(locationFieldset);
        form.appendChild(distanceFieldset);
        container.appendChild(form);
    },
Example #4
0
  createTile: function (coords, done) {
    var tile = document.createElement('img');

    L.DomEvent.on(tile, 'load', L.bind(this._tileOnLoad, this, done, tile));
    L.DomEvent.on(tile, 'error', L.bind(this._tileOnError, this, done, tile));

    if (this.options.crossOrigin) {
      tile.crossOrigin = '';
    }

    /*
     Alt tag is set to empty string to keep screen readers from reading URL and for compliance reasons
     http://www.w3.org/TR/WCAG20-TECHS/H67
    */
    tile.alt = '';

    // if there is no lod map or an lod map with a proper zoom load the tile
    // otherwise wait for the lod map to become available
    if (!this._lodMap || (this._lodMap && this._lodMap[coords.z])) {
      tile.src = this.getTileUrl(coords);
    } else {
      this.once('lodmap', function () {
        tile.src = this.getTileUrl(coords);
      }, this);
    }

    return tile;
  },
Example #5
0
	onAdd: function ( map ) {
		var container = L.DomUtil.create( 'div', 'leaflet-bar' ),
			link = L.DomUtil.create( 'a', 'mw-kartographer-icon-nearby', container ),
			pruneCluster = new PruneClusterForLeaflet( 70 ),
			control = this;

		link.href = '#';
		link.title = mw.msg( 'kartographer-wv-nearby-articles-control' );
		pruneCluster.options = {
			wvIsOverlay: true,
			wvIsExternal: true,
			wvName: 'nearby-articles'
		};

		this.map = map;
		this.link = link;
		this.pruneCluster = pruneCluster;

		L.DomEvent.addListener( link, 'click', this._onToggleNearbyLayer, this );
		L.DomEvent.disableClickPropagation( container );

		map.on( 'overlayadd', this._onOverlayAdd, this );
		map.on( 'overlayremove', this._onOverlayRemove, this );

		return container;
	},
    _userLocationSelected: function(evt) {
        L.DomEvent.stopPropagation(evt);
        L.DomEvent.preventDefault(evt);

        this._deactivateUserLocationSelection();

        this._map.fire('user-location-selected', {
            latlng: evt.latlng
        });
    }
    _initLayout: function () {
        var className = 'leaflet-control-layers';
        this._container = L.DomUtil.create('div', '');

        //Makes this work on IE10 Touch devices by stopping it 
        //from firing a mouseout event when the touch is released
        this._container.setAttribute('aria-haspopup', true);

        if (!L.Browser.touch) {
            L.DomEvent
                .disableClickPropagation(this._container)
                .disableScrollPropagation(this._container);
        } else {
            L.DomEvent.on(
                this._container,
                'click',
                L.DomEvent.stopPropagation
            );
        }

        this._form = L.DomUtil.create('form', className + '-list');

        this._map.on('click', this._collapse, this);
        this._overlaysList = L.DomUtil.create(
            'div',
            className + '-overlays',
            this._form
        );

        this._closeDiv = L.DomUtil.create('div', 'clearfix');
        var closeBtn = L.DomUtil.create(
            'button',
            'btn btn-default pull-right',
            this._closeDiv
        );
        closeBtn.title = 'Kartlag';
        L.DomEvent.on(closeBtn, 'click', function () {
            this._toggle();
        }, this);

        this._errorIcon = L.DomUtil.create('i', 'error-icon fa fa-exclamation-triangle hidden', closeBtn);
        closeBtn.appendChild(document.createTextNode(' '));
        if (this.numLoading > 0) {
            this._btnIcon = L.DomUtil.create('i', 'fa fa-spinner fa-pulse', closeBtn);
        } else {
            this._btnIcon = L.DomUtil.create('i', 'fa fa-bars', closeBtn);
        }

        this._container.appendChild(this._closeDiv);

        this._listContainer = L.DomUtil.create('div', className + ' hidden');
        this._listContainer.appendChild(this._form);
        this._container.appendChild(this._listContainer);
    },
		onAdd: function() {
			this._container = L.DomUtil.create('div', 'leaflet-routing-container leaflet-bar ' +
				(!this.options.show ? 'leaflet-routing-container-hide' : '') +
				this.options.containerClassName);
			this._altContainer = this.createAlternativesContainer();
			this._container.appendChild(this._altContainer);
			L.DomEvent.disableClickPropagation(this._container);
			L.DomEvent.addListener(this._container, 'mousewheel', function(e) {
				L.DomEvent.stopPropagation(e);
			});
			return this._container;
		},
    _userLocationSelected: function(evt) {
        L.DomEvent.stopPropagation(evt);
        L.DomEvent.preventDefault(evt);

        var location = evt.latlng.lat+","+evt.latlng.lng;
        $(this._definedLocationInput).val(location);
        this._filter.location = location;

        this.fire('filter', { filter: this._filter });

        this._deactivateLocationSelect();
    },
    onAdd: function(map) {
        var container = this.createContainer();

        // Copied directly from the parent class.
        if (!L.Browser.touch) {
            L.DomEvent
                .disableClickPropagation(container)
                .disableScrollPropagation(container);
        } else {
            L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation);
        }
        this.streamFeatures.addTo(map);
        return container;
    },
    _initLayout: function() {
        var className = 'leaflet-control-layers',
            container = this._container = new LayerControlButtonView({}).render().el,
            listContainer = this._listContainer = new LayerControlListView({}).render().el;

        this._form = $(listContainer).find('form').get(0);

        // Copied directly from the parent class.
        // makes this work on IE touch devices by stopping it
        // from firing a mouseout event when the touch is released
        container.setAttribute('aria-haspopup', true);

        // Copied directly from the parent class.
        if (!L.Browser.touch) {
            L.DomEvent
                .disableClickPropagation(container)
                .disableScrollPropagation(container);

            L.DomEvent
                .disableClickPropagation(listContainer)
                .disableScrollPropagation(listContainer);
        } else {
            L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation);
            L.DomEvent.on(listContainer, 'click', L.DomEvent.stopPropagation);
        }

        // Expand the layer control so that Leaflet
        // knows it's shown. We don't toggle this, but
        // instead we toggle visibility using our own
        // methods.
        this._expand();

        // Kept around so we don't have to override _update, even though
        // it's not used in the UI.
        this._separator = L.DomUtil.create('div', className + '-separator');

        // Add container element for each layer type
        this._baseLayersList = L.DomUtil.create('div', className + '-base',
                $(listContainer).find("#basemap-layer-list").get(0));
        this._overlaysList = L.DomUtil.create('div', className + '-overlay',
                $(listContainer).find("#overlays-layer-list").get(0));
        this._observationList = L.DomUtil.create('div', className + '-observation',
                $(listContainer).find("#observations-layer-list").get(0));

        // Add the layer control list as a sibling to the map.
        // This lets us control the size of the list based
        // on the height of the map.
        $('#map').append(listContainer);
    },
    _initLayout: function () {
        var class_name = 'leaflet-control-filter',
            container = this._container = L.DomUtil.create('div', class_name);

        if (!L.Browser.touch) {
            L.DomEvent.disableClickPropagation(container);
            L.DomEvent.on(container, 'mousewheel', L.DomEvent.stopPropagation);
        } else {
            L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation);
        }

        var form = this._form = L.DomUtil.create('form', class_name + '-list');

        container.appendChild(form);
    },
Example #13
0
  toImage: function() {
    var img = new Image();
    // this doesn't work in IE, force size
    // img.style.height = img.style.width = '100%';
    img.style.width = this._size.x + 'px';
    img.style.height = this._size.y + 'px';
    img.src = this.toBase64();

    var canvas = this._canvas || L.DomUtil.create('canvas', 'schematic-canvas');
    var ctx = canvas.getContext('2d');

    L.DomEvent.on(img, 'load', function () {
      var naturalSize = L.point(img.offsetWidth, img.offsetHeight);
      //console.log('natural', naturalSize);
      this._reset();
    }, this);

    if (!this._canvas) {
      this._canvas = canvas;
      this._container.insertBefore(canvas, this._container.firstChild);
    }
    img.style.opacity = 0;

    if (this._raster) {
      this._raster.parentNode.removeChild(this._raster);
      this._raster = null;
    }

    L.DomUtil.addClass(img, 'schematic-image');
    this._container.appendChild(img);
    this._raster = img;
    return this;
  },
Example #14
0
        setTimeout(function () {
            if (internalMap.clicked == 1) {
                // at first click display a popup
                if (!routingControl.getWaypoints()[0].latLng) {
                    let container = L.DomUtil.create('div');
                    let startBtn = createRoutePlannerButton('Start route from this location', container);

                    L.DomEvent.on(startBtn, 'click', function () {
                        routingControl.spliceWaypoints(0, 1, e.latlng);
                        internalMap.closePopup();
                    });

                    L.popup()
                        .setContent(container)
                        .setLatLng(e.latlng)
                        .openOn(internalMap);

                } else if (routingControl.getWaypoints().length == 2 && !routingControl.getWaypoints()[1].latLng) {
                    // then fill the coords of the last waypoint
                    routingControl.spliceWaypoints(routingControl.getWaypoints().length - 1, 1, e.latlng);
                } else {
                    // then add the new waypoint to the end
                    var lastWaypoint = routingControl.getWaypoints()[routingControl.getWaypoints().length - 1].latLng;
                    routingControl.spliceWaypoints(routingControl.getWaypoints().length - 1, 1, lastWaypoint, e.latlng);
                }
                internalMap.clicked = 0;
            }
        }, 300);
  disable: function() {
    if (this._enabled) {
      this.map
        .off('dragend',  this._focus, this)
        .off('zoomanim', this._animateZoom, this)
        .off('zoomend',  this._updateTextAreaBounds, this);

      if (null !== this._textArea) {
        this.getText();
        L.DomEvent.removeListener(this._textArea, 'keypress',
          L.DomEvent.stopPropagation);
        this._textArea.parentNode.removeChild(this._textArea);
        this._textArea = null;
      }
      this.feature._text = this._text;

      if (this.map.hasLayer(this.feature)) {
        this.feature._renderText();
      }
    }

    L.Editable.RectangleEditor.prototype.disable.call(this);

    return this;
  },
    onAdd: function (map) {
        // control container
        var container = L.DomUtil.create('div',
            'leaflet-control-setuserlocation leaflet-bar leaflet-control');

        // map reference
        this._map = map;

        // map pane reference
        this._mapPane = map.getPanes()['mapPane'];

        this._active = false;

        // Construct the toggle link
        this._link = L.DomUtil.create('a', 'leaflet-bar-part leaflet-bar-part-single ' + this.options.icon, container);
        this._link.href = 'javascript:void(0);';
        this._link.title = this.options.strings.title;

        // bind link click event
        L.DomEvent
            .on(this._link, 'click', L.DomEvent.stopPropagation)
            .on(this._link, 'click', L.DomEvent.preventDefault)
            .on(this._link, 'click', function() {
                this._toggleUserLocationSelection();
            }, this)
            .on(this._link, 'dblclick', L.DomEvent.stopPropagation)
            .on(this._link, 'dblclick', L.DomEvent.preventDefault);

        return container;
    },
		_onAltClicked: function(e) {
			var altElem,
			    j,
			    n,
			    isCurrentSelection,
			    classFn;

			altElem = e.target || window.event.srcElement;
			while (!L.DomUtil.hasClass(altElem, 'leaflet-routing-alt')) {
				altElem = altElem.parentElement;
			}

			if (L.DomUtil.hasClass(altElem, 'leaflet-routing-alt-minimized')) {
				for (j = 0; j < this._altElements.length; j++) {
					n = this._altElements[j];
					isCurrentSelection = altElem === n;
					classFn = isCurrentSelection ? 'removeClass' : 'addClass';
					L.DomUtil[classFn](n, 'leaflet-routing-alt-minimized');
					if (this.options.minimizedClassName) {
						L.DomUtil[classFn](n, this.options.minimizedClassName);
					}

					if (isCurrentSelection) {
						// TODO: don't fire if the currently active is clicked
						this.fire('routeselected', {route: this._routes[j]});
					} else {
						n.scrollTop = 0;
					}
				}
			}

			L.DomEvent.stop(e);
		},
  _finishMeasure: function () {
    var model = _.extend({}, this._resultsModel, {
      points: this._latlngs
    });

    this._locked = false;

    if (this._wasDoubleClickEnabled) {
      this._map.doubleClickZoom.enable();
    }
    this._map.off('mouseout', this._handleMapMouseOut, this);

    L.DomEvent.off(this._container, 'mouseover', this._handleMapMouseOut, this);

    this._clearMeasure();

    this._map.off('mousemove', this._handleMeasureMove, this);
    this._map.off('dblclick', this._handleMeasureDoubleClick, this);
    this._map.off('click', this._handleMeasureClick, this);

    this._layer.removeLayer(this._measureVertexes);
    this._measureVertexes = null;

    this._updateMeasureNotStarted();
    this._collapse();

    this._map.fire('measurefinish', model, false);
  },
	    onAdd: function(leafletMap) {
		this._container = leaflet.DomUtil.create('div', 'load-viewpoint-button leaflet-bar');
		this._container.title = "Load a saved viwpoint.";
		this.link = leaflet.DomUtil.create('a', this.options.classname, this._container);
		this.link.href = "#";
		this.link.innerHTML = "V";
		
		leaflet.DomEvent
		    .on(this._container, 'dblclick', leaflet.DomEvent.stop)
		    .on(this._container, 'click', leaflet.DomEvent.stop)
		    .on(
			this._container,
			'click',
			function() {
			    var viewpoint = getViewpoint();
			    
			    setView(
				viewpoint.coordinates(),
				viewpoint.zoom()
			    );

			    update();
			},
			this
		    );

		this.savedIndicatorWrapper = leaflet.DomUtil.create('div', 'viewpoint-saved-indicator-wrapper', this._container);
		this.savedIndicator = leaflet.DomUtil.create('div', 'viewpoint-saved-indicator', this.savedIndicatorWrapper);
		this.savedIndicator.innerHTML = 'Viewpoint saved';
		
		return this._container;
	    }
    onAdd: function(map) {
        var self = this,
            $el = $(canopyFilterTmpl());

        $el.find('[name="canopy-slider"]').ionRangeSlider({
            type: 'double',
            min: 0,
            max: 100,
            from: 0,
            to: 100,
            step: 1,
            drag_interval: true,
            hide_min_max: true,
            grid: false,
            postfix: '%',
            onChange: function (data) {
                self._changeBus.push({
                    canopyMin: data.from / 100,
                    canopyMax: data.to / 100
                });
            },
        });

        var el = $el.get(0);
        L.DomEvent.disableClickPropagation(el);
        return el;
    }
		_addRowListeners: function(row, coordinate) {
			var _this = this,
			    marker;
			L.DomEvent.addListener(row, 'mouseover', function() {
				marker = L.circleMarker(coordinate,
					_this.options.pointMarkerStyle).addTo(_this._map);
			});
			L.DomEvent.addListener(row, 'mouseout', function() {
				if (marker) {
					_this._map.removeLayer(marker);
					marker = null;
				}
			});
			L.DomEvent.addListener(row, 'click', function(e) {
				_this._map.panTo(coordinate);
				L.DomEvent.stopPropagation(e);
			});
		},
Example #22
0
function addFunction() {
	var div = L.DomUtil.create('form', 'bgroup');
	div.id = "dropzone";
	var bgroup = L.DomUtil.create('div','btn-group',div);
	var doneButton = L.DomUtil.create('button', "btn  btn-primary span3", bgroup);
	doneButton.type = "button";
	doneButton.innerHTML = "select a zipped .GDB";
	L.DomEvent.addListener(doneButton, "click", function() {
		fileInput.click();
	});
	var dirButton = L.DomUtil.create('button', "btn  btn-primary span3", bgroup);
	dirButton.type = "button";
	dirButton.innerHTML = "upload the files in a .GDB folder";
	L.DomEvent.addListener(dirButton, "click", function() {
		dirInput.click();
	});
	return div;
}
 _onMouseClick: function (e) {
   if (this._wasMoving) {
     // Do not trigger click if pointer was moving around.
     return
   }
   const event = (e.touches && e.touches[0]) || (e.changedTouches && e.changedTouches[0]) || e
   const pos = DomEvent.getMousePosition(event, this._canvas)
   this.onMouseClick(e, pos)
 }
Example #24
0
    layersControl._initLayout = function () {
		    var className = 'leaflet-control-layers',
		        container = this._container = L.DomUtil.create('div', className);

		    // makes this work on IE touch devices by stopping it from firing a mouseout event when the touch is released
		    container.setAttribute('aria-haspopup', true);

        // Original source for disableClickPropagation taken from
        // https://github.com/Leaflet/Leaflet/blob/v1.0.1/src/dom/DomEvent.js#L179-L188
        var stop = L.DomEvent.stopPropagation;
		    L.DomEvent.on(container, 'mousedown', stop);
		    L.DomEvent.on(container, {
			      click: L.DomEvent._fakeStop,
			      dblclick: stop
		    });

		    if (!L.Browser.touch) {
			      L.DomEvent.disableScrollPropagation(container);
		    }

		    var form = this._form = L.DomUtil.create('form', className + '-list');

		    if (this.options.collapsed) {
			      if (!L.Browser.android) {
				        L.DomEvent.on(container, {
					          mouseenter: this.expand,
					          mouseleave: this.collapse
				        }, this);
			      }

			      var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);
			      link.href = '#';
			      link.title = 'Layers';

			      if (L.Browser.touch) {
				        L.DomEvent
				            .on(link, 'click', L.DomEvent.stop)
				            .on(link, 'click', this.expand, this);
			      } else {
				        L.DomEvent.on(link, 'focus', this.expand, this);
			      }

			      // work around for Firefox Android issue https://github.com/Leaflet/Leaflet/issues/2033
			      L.DomEvent.on(form, 'click', function () {
				        setTimeout(L.bind(this._onInputClick, this), 0);
			      }, this);

			      this._map.on('click', this.collapse, this);
			      // TODO keyboard accessibility
		    } else {
			      this.expand();
		    }

		    this._baseLayersList = L.DomUtil.create('div', className + '-base', form);
		    this._separator = L.DomUtil.create('div', className + '-separator', form);
		    this._overlaysList = L.DomUtil.create('div', className + '-overlays', form);

		    container.appendChild(form);
	  };
Example #25
0
 .on(form, 'submit', function (evt) {
   L.DomEvent.stop(evt);
   var radios = Array.prototype.slice.call(
     form.querySelectorAll('input[type=radio]'));
   for (var i = 0, len = radios.length; i < len; i++) {
     if (radios[i].checked) {
       this.options.callback(parseInt(radios[i].value));
       break;
     }
   }
 }, this)
Example #26
0
  onAdd: function() {
    var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control');

    this.link = L.DomUtil.create('a', 'leaflet-bar-part location-arrow',
      container);
    this.link.href = '#';
    L.DomEvent.on(this.link, 'click', this._click, this);
    this.link.title = this.options.title;

    return container;
  },
    onAdd : function (map) {
        // initialisation du DOM du composant
        var container = this._container = this._initLayout(map);

        // deactivate of events that may interfere with the map
        L.DomEvent
            .disableClickPropagation(container)
            .disableScrollPropagation(container);

        return container;
    },
 mouseDownHandler = function mouseDownHandler(e) {
   // In some browsers, a click will fire on the map if the control is
   // collapsed directly after mousedown. To work around this, we
   // wait until the click is completed, and _then_ collapse the
   // control. Messy, but this is the workaround I could come up with
   // for #142.
   this._preventBlurCollapse = true;
   L.DomEvent.stop(e);
   this._geocodeResultSelected(result);
   L.DomEvent.on(
     li,
     'click',
     function() {
       if (this.options.collapsed) {
         this._collapse();
       } else {
         this._clearResults();
       }
     },
     this
   );
 };
 _removeEventHandlers: function () {
   DomEvent.off(this._canvas, 'mousedown', this._onMouseDown)
   DomEvent.off(this._canvas, 'touchstart', this._onMouseDown)
   DomEvent.off(this._canvas, 'mousemove', this._onMouseMove)
   DomEvent.off(this._canvas, 'touchmove', this._onMouseMove)
   DomEvent.off(this._canvas, 'mouseup', this._onMouseClick)
   DomEvent.off(this._canvas, 'touchend', this._onMouseClick)
 },
 _initEventHandlers: function () {
   DomEvent.on(this._canvas, 'mousedown', this._onMouseDown, this)
   DomEvent.on(this._canvas, 'touchstart', this._onMouseDown, this)
   DomEvent.on(this._canvas, 'mousemove', this._onMouseMove, this)
   DomEvent.on(this._canvas, 'touchmove', this._onMouseMove, this)
   DomEvent.on(this._canvas, 'mouseup', this._onMouseClick, this)
   DomEvent.on(this._canvas, 'touchend', this._onMouseClick, this)
 },