|
@@ -1,5 +1,5 @@
|
|
|
import {Component, OnInit} from '@angular/core';
|
|
|
-import {geoJSON, GeoJSON, icon, LatLng, latLng, marker, polyline, tileLayer} from 'leaflet';
|
|
|
+import {geoJSON, GeoJSON, icon, LatLng, latLng, map, marker, polyline, tileLayer} from 'leaflet';
|
|
|
import {VttTraceWsService} from './vtt-trace-ws.service';
|
|
|
import {Feature, LineString, MultiLineString, Point} from 'geojson';
|
|
|
import {VttTraceFormNewTraceComponent} from './vtt-trace.formNewTraceComponent';
|
|
@@ -132,6 +132,12 @@ export class VttTraceComponent implements OnInit {
|
|
|
this.addRoute6();
|
|
|
}
|
|
|
|
|
|
+ resetLayers () {
|
|
|
+ console.log('Resetting layers');
|
|
|
+ // console.log(`Here\'s the counter: ${this.counter}`);
|
|
|
+ this.layers = [];
|
|
|
+ }
|
|
|
+
|
|
|
private getMarkersObs() {
|
|
|
this.vttTraceWs.gettVttRandosDescFromServerObs()
|
|
|
.subscribe((response: Array<string>) => {
|
|
@@ -177,17 +183,26 @@ export class VttTraceComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
markerOnClick(e) {
|
|
|
+ console.log(e.sourceTarget._latlng);
|
|
|
const attributes = e.sourceTarget.options;
|
|
|
console.log(attributes.title);
|
|
|
// do some stuff…
|
|
|
// this.addTrace('' + attributes.title);
|
|
|
console.log(attributes);
|
|
|
- this.options.zoom = 9;
|
|
|
+ this.centerAndZoom(e.sourceTarget._latlng.lat, e.sourceTarget._latlng.lng, 9);
|
|
|
+ this.zoom = 9;
|
|
|
+ this.latitude = e.sourceTarget._latlng.lat;
|
|
|
+ this.longitude = e.sourceTarget._latlng.lng;
|
|
|
+ this.onApply();
|
|
|
+ this.resetLayers();
|
|
|
+ // How to refresh automaticaly the map???
|
|
|
+ // this._onResize();
|
|
|
+ // this.geoJSON.layer.addEventParent(geoJSON.);
|
|
|
|
|
|
this.vttTraceWs.getTraceFromFile(attributes.title)
|
|
|
.subscribe(data => {
|
|
|
// console.log(data);
|
|
|
- const featureCollection: GeoJSON.FeatureCollection<Point | LineString | MultiLineString> = data
|
|
|
+ const featureCollection: GeoJSON.FeatureCollection<Point | LineString | MultiLineString> = data;
|
|
|
// const g = featureCollection.features[0].geometry.coordinates;
|
|
|
// console.log(featureCollection.features[0].geometry.coordinates[0]);
|
|
|
// this.layers.push(polyline(GeoJSON.coordsToLatLngs(g, 1)));
|
|
@@ -207,8 +222,8 @@ export class VttTraceComponent implements OnInit {
|
|
|
addTrace(fileName: string) {
|
|
|
this.vttTraceWs.getTraceFromFile(fileName)
|
|
|
.subscribe(data => {
|
|
|
- console.log(data)
|
|
|
- const featureCollection: GeoJSON.FeatureCollection<Point | LineString | MultiLineString> = data
|
|
|
+ console.log(data);
|
|
|
+ const featureCollection: GeoJSON.FeatureCollection<Point | LineString | MultiLineString> = data;
|
|
|
const g = featureCollection.features[0].geometry.coordinates;
|
|
|
console.log(featureCollection.features[0].geometry.coordinates[0]);
|
|
|
this.layers.push(polyline(GeoJSON.coordsToLatLngs(g, 1)));
|
|
@@ -216,6 +231,14 @@ export class VttTraceComponent implements OnInit {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ centerAndZoom(lat, lng, zoom) {
|
|
|
+ this.zoom = zoom;
|
|
|
+ this.center = latLng(lat, lng);
|
|
|
+
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
addRoute() {
|
|
|
// create a red polyline from an array of LatLng points
|
|
|
const route = polyline(this.vttTraceWs.getMockRoute1());
|
|
@@ -233,8 +256,8 @@ export class VttTraceComponent implements OnInit {
|
|
|
addRoute4() {
|
|
|
this.vttTraceWs.getMockRoute4()
|
|
|
.subscribe(data => {
|
|
|
- console.log(data)
|
|
|
- const featureCollection: GeoJSON.FeatureCollection<Point | LineString | MultiLineString> = data
|
|
|
+ console.log(data);
|
|
|
+ const featureCollection: GeoJSON.FeatureCollection<Point | LineString | MultiLineString> = data;
|
|
|
const g = featureCollection.features[1].geometry.coordinates;
|
|
|
// console.log(g);
|
|
|
console.log(featureCollection.features[1].geometry.coordinates[0]);
|
|
@@ -247,8 +270,8 @@ export class VttTraceComponent implements OnInit {
|
|
|
addRoute5() {
|
|
|
this.vttTraceWs.getMockRoute5()
|
|
|
.subscribe(data => {
|
|
|
- console.log(data)
|
|
|
- const featureCollection: GeoJSON.FeatureCollection<Point | LineString | MultiLineString> = data
|
|
|
+ console.log(data);
|
|
|
+ const featureCollection: GeoJSON.FeatureCollection<Point | LineString | MultiLineString> = data;
|
|
|
const g = featureCollection.features[0].geometry.coordinates;
|
|
|
console.log(featureCollection.features[0].geometry.coordinates[0]);
|
|
|
this.layers.push(polyline(GeoJSON.coordsToLatLngs(g, 1)));
|
|
@@ -258,8 +281,8 @@ export class VttTraceComponent implements OnInit {
|
|
|
addRoute6() {
|
|
|
this.vttTraceWs.getMockRoute6()
|
|
|
.subscribe(data => {
|
|
|
- console.log(data)
|
|
|
- const featureCollection: GeoJSON.FeatureCollection<Point | LineString | MultiLineString> = data
|
|
|
+ console.log(data);
|
|
|
+ const featureCollection: GeoJSON.FeatureCollection<Point | LineString | MultiLineString> = data;
|
|
|
const g = featureCollection.features[0].geometry.coordinates;
|
|
|
console.log(featureCollection.features[0].geometry.coordinates[0]);
|
|
|
this.layers.push(polyline(GeoJSON.coordsToLatLngs(g, 1)));
|