leaflet#Util TypeScript Examples

The following examples show how to use leaflet#Util. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CoordinatesControl.ts    From LiveAtlas with Apache License 2.0 6 votes vote down vote up
constructor(options: CoordinatesControlOptions) {
		super(options);

		this._coordsContainer = DomUtil.create('span', 'value coordinates');
		this._chunkContainer = DomUtil.create('span', 'value chunk');
		this._regionContainer = DomUtil.create('span', 'value region');

		options.position = 'bottomleft';
		Util.setOptions(this, options);
	}
Example #2
Source File: PlayerMarker.ts    From LiveAtlas with Apache License 2.0 6 votes vote down vote up
constructor(player: LiveAtlasPlayer, options: PlayerMarkerOptions) {
		super(new LatLng(0, 0), options);
		this._player = player;

		this._PlayerIcon = options.icon = new PlayerIcon(player, {
			imageSize: options.imageSize,
			showHealth: options.showHealth,
			showArmor: options.showArmor,
			showYaw: options.showYaw,
			compact: options.compact,
		});

		Util.setOptions(this, options);
	}
Example #3
Source File: LiveAtlasTileLayer.ts    From LiveAtlas with Apache License 2.0 6 votes vote down vote up
protected constructor(options: LiveAtlasTileLayerOptions) {
		super('', {
			errorTileUrl: 'images/blank.png',
			zoomReverse: true,
			tileSize: options.tileSize,
			maxNativeZoom: options.nativeZoomLevels,
			minZoom: options.minZoom,
			maxZoom: options.maxZoom || options.nativeZoomLevels + (options.extraZoomLevels || 0),
		});

		Util.setOptions(this, {
			imageFormat: options.imageFormat,
			baseUrl: options.baseUrl,
			tileUpdateInterval: options.tileUpdateInterval,
			nightAndDay: !!options.nightAndDay,
			prefix: options.prefix || '',
			extraZoomLevels: options.extraZoomLevels || 0,
			nativeZoomLevels: options.nativeZoomLevels,
		});

		this.tileTemplate = DomUtil.create('img', 'leaflet-tile') as LiveAtlasTileElement;
		this.tileTemplate.style.width = this.tileTemplate.style.height = this.options.tileSize + 'px';
		this.tileTemplate.alt = '';
		this.tileTemplate.tileName = '';
		this.tileTemplate.callback = falseFn;
		this.tileTemplate.setAttribute('role', 'presentation');

		if(this.options.crossOrigin || this.options.crossOrigin === '') {
			this.tileTemplate.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;
		}

		Object.seal(this.tileTemplate);
	}
Example #4
Source File: ClockControl.ts    From LiveAtlas with Apache License 2.0 5 votes vote down vote up
constructor(options: ClockControlOptions) {
		super(Object.assign(options, {position: 'topcenter'}));

		Util.setOptions(this, options);
	}
Example #5
Source File: LiveAtlasLayerControl.ts    From LiveAtlas with Apache License 2.0 5 votes vote down vote up
hasLayer(layer: Layer): boolean {
		// @ts-ignore
		return !!super._getLayer(Util.stamp(layer));
	}
Example #6
Source File: LiveAtlasLayerControl.ts    From LiveAtlas with Apache License 2.0 5 votes vote down vote up
// noinspection JSUnusedGlobalSymbols
	_addItem(obj: any) {
		const container = obj.overlay ? this._overlaysList : this._baseLayersList,
			item = document.createElement('label'),
			label = document.createElement('span'),
			checked = this._map!.hasLayer(obj.layer);

		let input;

		item.className = 'layer checkbox';

		if (obj.overlay) {
			input = document.createElement('input');
			input.type = 'checkbox';
			input.className = 'leaflet-control-layers-selector';
			input.defaultChecked = checked;
		} else {
			// @ts-ignore
			input = super._createRadioElement('leaflet-base-layers_' + Util.stamp(this), checked);
		}

		input.layerId = Util.stamp(obj.layer);
		this._layerControlInputs!.push(input);
		label.textContent = obj.name;

		// @ts-ignore
		DomEvent.on(input, 'click', (e: LeafletEvent) => super._onInputClick(e), this);

		item.appendChild(input);
		item.insertAdjacentHTML('beforeend',  `
		<svg class="svg-icon" aria-hidden="true">
	  		<use xlink:href="#icon--checkbox" />
		</svg>`);
		item.appendChild(label);

		container!.appendChild(item);

		// @ts-ignore
		super._checkDisabledLayers();
		return label;
	}
Example #7
Source File: GenericIcon.ts    From LiveAtlas with Apache License 2.0 5 votes vote down vote up
constructor(options: GenericIconOptions) {
		super(options as LayerOptions);
		Util.setOptions(this, Object.assign(defaultOptions, options));
	}
Example #8
Source File: PlayerIcon.ts    From LiveAtlas with Apache License 2.0 5 votes vote down vote up
constructor(player: LiveAtlasPlayer, options: PlayerIconOptions) {
		super(options as LayerOptions);
		Util.setOptions(this, options);
		this._player = player;
	}
Example #9
Source File: LiveAtlasLayerGroup.ts    From LiveAtlas with Apache License 2.0 5 votes vote down vote up
constructor(options: LiveAtlasLayerGroupOptions) {
		super([], options);
		Util.setOptions(this, options);

		this._zoomLimitedLayers = new Set();
	}
Example #10
Source File: OverviewerTileLayer.ts    From LiveAtlas with Apache License 2.0 5 votes vote down vote up
constructor(options: LiveAtlasTileLayerOptions) {
		super(options);

		Util.setOptions(this, {zoomReverse: false});
	}
Example #11
Source File: Pl3xmapTileLayer.ts    From LiveAtlas with Apache License 2.0 5 votes vote down vote up
constructor(map: LiveAtlasTileLayerOptions) {
		super(map);
		this._url = `${map.baseUrl}{z}/{x}_{y}.png`;
		Util.setOptions(this, {zoomReverse: false});
	}