This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Component, OnInit, ElementRef, ViewChild } from "@angular/core";
|
||||
import { Component, OnInit, ElementRef, ViewChild } from '@angular/core';
|
||||
import * as L from 'leaflet';
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
selector: 'tile-map',
|
||||
selector: 'app-tile-map',
|
||||
templateUrl: './tile-map.component.html'
|
||||
})
|
||||
export class TileMapComponent implements OnInit {
|
||||
@@ -14,10 +14,10 @@ export class TileMapComponent implements OnInit {
|
||||
private static readonly DEFAULT_ICON_SCALE = 0.2;
|
||||
|
||||
|
||||
private static readonly DEFAULT_PIN_URL = "assets/markers/marker_pin.png";
|
||||
private static readonly DEFAULT_NORMAL_URL = "assets/markers/marker_normal.png";
|
||||
private static readonly DEFAULT_SELECTED_URL = "assets/markers/marker_selected.png";
|
||||
private static readonly DEFAULT_SHADOW_URL = "assets/markers/marker_shadow.png";
|
||||
private static readonly DEFAULT_PIN_URL = 'assets/markers/marker_pin.png';
|
||||
private static readonly DEFAULT_NORMAL_URL = 'assets/markers/marker_normal.png';
|
||||
private static readonly DEFAULT_SELECTED_URL = 'assets/markers/marker_selected.png';
|
||||
private static readonly DEFAULT_SHADOW_URL = 'assets/markers/marker_shadow.png';
|
||||
|
||||
@ViewChild('map', { read: ElementRef, static: true }) mapElement: ElementRef;
|
||||
|
||||
@@ -32,7 +32,7 @@ export class TileMapComponent implements OnInit {
|
||||
this.iconNormal = this.createMarkerIcon(TileMapComponent.DEFAULT_NORMAL_URL);
|
||||
this.iconSelected = this.createMarkerIcon(TileMapComponent.DEFAULT_NORMAL_URL);
|
||||
this.iconPin = this.createPinIcon(TileMapComponent.DEFAULT_PIN_URL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
getWidth(): number {
|
||||
@@ -60,8 +60,8 @@ export class TileMapComponent implements OnInit {
|
||||
}).addTo(this.map);
|
||||
}
|
||||
|
||||
private createMarkerIcon(url: string):L.Icon {
|
||||
let href = this.getBaseHref();
|
||||
private createMarkerIcon(url: string): L.Icon {
|
||||
const href = this.getBaseHref();
|
||||
return new L.Icon({
|
||||
iconUrl: href + url,
|
||||
shadowUrl: href + TileMapComponent.DEFAULT_SHADOW_URL,
|
||||
@@ -72,8 +72,8 @@ export class TileMapComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private createPinIcon(url: string):L.Icon {
|
||||
let href = this.getBaseHref();
|
||||
private createPinIcon(url: string): L.Icon {
|
||||
const href = this.getBaseHref();
|
||||
return new L.Icon({
|
||||
iconUrl: href + url,
|
||||
iconAnchor: [this.scale(100), this.scale(100)],
|
||||
@@ -81,18 +81,18 @@ export class TileMapComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private getBaseHref():string{
|
||||
let bases = document.getElementsByTagName('base');
|
||||
private getBaseHref(): string {
|
||||
const bases = document.getElementsByTagName('base');
|
||||
let baseHref = null;
|
||||
if (bases.length > 0) baseHref = bases[0].href;
|
||||
if (baseHref == null) baseHref = "/";
|
||||
if (bases.length > 0) { baseHref = bases[0].href; }
|
||||
if (baseHref == null) { baseHref = '/'; }
|
||||
return baseHref;
|
||||
}
|
||||
|
||||
private scale(v:number):number {
|
||||
private scale(v: number): number {
|
||||
return v * TileMapComponent.DEFAULT_ICON_SCALE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user