Skip to content

Commit

Permalink
Merge 45854cb into 1da9f2e
Browse files Browse the repository at this point in the history
  • Loading branch information
atd-schubert committed Feb 12, 2018
2 parents 1da9f2e + 45854cb commit 976153d
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 2 deletions.
29 changes: 28 additions & 1 deletion ts/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,39 @@

import { PathOptions } from 'leaflet';

/**
* Base64 data-url for a transparent 1px png image
*/
export const TRANSPARENT_PIXEL: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
/**
* Default value for delays caused by animations (in milliseconds)
*/
export const ANIMATION_DELAY: number = 50;
/**
* Some lorem ipsum test content
*/
export const EXAMPLE_CONTENT: string = 'Vel ipsum odit quia velit omnis illo voluptatem ut. Aperiam porro voluptates maiores.';
/**
* URL-schema of the official osm tile-server
*/
export const OSM_TILE_LAYER_URL: string = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
export const IMAGE_OVERLAY_URL: string = 'http://live.osgeo.org/_images/osgeolive_menu6.png';
/**
* URL for an example image for image-overlays
*/
export const IMAGE_OVERLAY_URL: string = 'http://download.osgeo.org/livedvd/10.0/desktop10_osmF32.png';
/**
* Base URL for a sample WMS service
*/
export const EXAMPLE_WMS_LAYER_URL: string = 'http://www.wms.nrw.de/geobasis/wms_nw_dtk?';
/**
* Layers of the example WMS service
*/
export const EXAMPLE_WMS_LAYER_NAMES: string[] = ['nw_dtk_col'];
/**
* Default attribution prefix
*/
export const ATTRIBUTION_PREFIX: string = '<a href="https://yagajs.org" title="YAGA">YAGA</a> | <a href="https://leaflet-ng2.yagajs.org" title="Leaflet in Angular2">leaflet-ng2</a>';
/**
* Empty default style
*/
export const DEFAULT_STYLE: PathOptions = {};
4 changes: 4 additions & 0 deletions ts/layer-group.provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Injectable } from '@angular/core';
import { LayerGroup, Map } from 'leaflet';

/**
* Injectable Angular provider to structure Leaflet layer-groups with Angulars DI
* @link http://leafletjs.com/reference-1.2.0.html#layer-group
*/
@Injectable()
export class LayerGroupProvider {
public ref: Map | LayerGroup;
Expand Down
4 changes: 4 additions & 0 deletions ts/layer.provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Injectable } from '@angular/core';
import { Layer } from 'leaflet';

/**
* Injectable Angular provider to structure Leaflet layers with Angulars DI
* @link http://leafletjs.com/reference-1.2.0.html#layer
*/
@Injectable()
export class LayerProvider {
public ref: Layer;
Expand Down
4 changes: 4 additions & 0 deletions ts/layers-control.provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Injectable } from '@angular/core';
import { Control } from 'leaflet';

/**
* Injectable Angular provider to reference to Leaflets layer-control
* @link http://leafletjs.com/reference-1.2.0.html#layer
*/
@Injectable()
export class LayersControlProvider {
public ref: Control.Layers;
Expand Down
4 changes: 4 additions & 0 deletions ts/map.provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Injectable } from '@angular/core';
import { Map } from 'leaflet';

/**
* Injectable Angular provider to reference to Leaflets map
* @link http://leafletjs.com/reference-1.2.0.html#map
*/
@Injectable()
export class MapProvider {
public ref: Map;
Expand Down
4 changes: 4 additions & 0 deletions ts/marker.provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Injectable } from '@angular/core';
import { Marker } from 'leaflet';

/**
* Injectable Angular provider for Leaflet icons to apply to them with Angular DI
* @link http://leafletjs.com/reference-1.2.0.html#marker
*/
@Injectable()
export class MarkerProvider {
public ref: Marker;
Expand Down
6 changes: 5 additions & 1 deletion ts/mouse-event-helper.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { LeafletMouseEvent, Map} from 'leaflet';

/**
* Helper function to enhance browser mouse events to Leaflet mouse events
* @private
*/
export function enhanceMouseEvent(originalEvent: MouseEvent, map: Map): LeafletMouseEvent {
return {
...originalEvent,
containerPoint: map.mouseEventToContainerPoint(originalEvent),
latlng: map.mouseEventToLatLng(originalEvent),
layerPoint: map.mouseEventToLayerPoint(originalEvent),
...originalEvent,
originalEvent,
} as any;
}
4 changes: 4 additions & 0 deletions ts/path-directives.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import {
} from './index';
import { randomNumber } from './spec';

/**
* Basic test for all path layers
* @private
*/
export function createPathTests(Constr: any): void {
describe('Path compatibility tests', () => {
let map: MapComponent;
Expand Down
24 changes: 24 additions & 0 deletions ts/spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
import { LatLng, LatLngBounds } from 'leaflet';

/**
* Helper function to create random numbers within a range
* @private
*/
export function randomNumber(max: number = 1, min: number = 0, after: number = 3) {
return (
Math.floor(
Math.random() * (Math.abs(max) + Math.abs(min)) * Math.pow(10, after),
) / Math.pow(10, after)) + min;
}

/**
* Helper function to create random latitude values
* @private
*/
export function randomLat() {
return randomNumber(90, -90);
}

/**
* Helper function to create random longitude values
* @private
*/
export function randomLng() {
return randomNumber(180, -180);
}

/**
* Helper function to create random latitude-longitude values pairs
* @private
*/
export function randomLatLng(): LatLng {
return new LatLng(randomLat(), randomLng());
}

/**
* Helper function to create random spatial bounds
* @private
*/
export function randomLatLngBounds(): LatLngBounds {
const lat1: number = randomLat();
const lat2: number = randomLat();
Expand All @@ -30,6 +50,10 @@ export function randomLatLngBounds(): LatLngBounds {
);
}

/**
* Helper function to detect if an element is a child of another
* @private
*/
export function hasAsChild(root: HTMLElement, child: HTMLElement): boolean {
const length: number = root.children.length;
for (let i: number = 0; i < length; i += 1) {
Expand Down

0 comments on commit 976153d

Please sign in to comment.