Commit fb2d2ca1 authored by Thomas Frion's avatar Thomas Frion

[UPDF] Use OpenTopoMap and refactor the code of map component

parent 06e3f333
......@@ -16,24 +16,31 @@ import { environment } from '../../environments/environment'
export class MapComponent implements OnInit {
private map;
private unit : UnitModel;
private tiles;
constructor() { }
ngOnInit(): void {
const unit : UnitModel = new UnitModel(
constructor() {
this.unit = new UnitModel(
JSON.parse(localStorage.getItem(environment.localStorage.unit))
);
this.map = L.map('map', {
center: this.getCoor(unit.geom),
zoom: unit.getSetting(UnitSetting.SettingName.Zoom).value //unit.settings[0].value
// https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
this.tiles = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, &copy; <a href="http://garmin.opentopomap.org/#right">OpentTopoMap</a>'
});
}
const tiles = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
ngOnInit(): void {
let marker = L.marker(this.getCoor(this.unit.geom));
this.map = L.map('map', {
center: this.getCoor(this.unit.geom),
zoom: this.unit.getSetting(UnitSetting.SettingName.Zoom).value //unit.settings[0].value
});
tiles.addTo(this.map);
marker.bindPopup("<b>" + this.unit.code + "</b> <br>" + this.unit.name);
this.tiles.addTo(this.map);
marker.addTo(this.map);
}
private getCoor(geom : string) : number[] {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment