|
@@ -132,12 +132,6 @@ 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>) => {
|
|
@@ -171,17 +165,6 @@ export class VttTraceComponent implements OnInit {
|
|
|
this.layers.push(newMarker);
|
|
|
}
|
|
|
|
|
|
- zoomAndCenter(latitude, longitude) {
|
|
|
- const window: Window = self;
|
|
|
- // console.log('parent' + this);
|
|
|
-
|
|
|
- this.zoom = 15;
|
|
|
- console.log(this.zoom);
|
|
|
- this.center = latLng(this.latitude, this.longitude);
|
|
|
- // this.options.center = e.latlng;
|
|
|
- // console.log(this.center);
|
|
|
- }
|
|
|
-
|
|
|
markerOnClick(e) {
|
|
|
console.log(e.sourceTarget._latlng);
|
|
|
const attributes = e.sourceTarget.options;
|
|
@@ -189,93 +172,43 @@ export class VttTraceComponent implements OnInit {
|
|
|
// do some stuff…
|
|
|
// this.addTrace('' + attributes.title);
|
|
|
console.log(attributes);
|
|
|
- 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 g = featureCollection.features[0].geometry.coordinates;
|
|
|
- // console.log(featureCollection.features[0].geometry.coordinates[0]);
|
|
|
- // this.layers.push(polyline(GeoJSON.coordsToLatLngs(g, 1)));
|
|
|
- // this.geoJSON.layer.addLayer(polyline(GeoJSON.coordsToLatLngs(g, 1))) ;
|
|
|
- console.log(this.geoJSON.layer.addData(featureCollection.features[0].geometry));
|
|
|
- /*this.geoJSON.layer = geoJSON(
|
|
|
- featureCollection.features[0].geometry as any,
|
|
|
- { style: () => ({ color: '#ff7800' })});*/
|
|
|
|
|
|
+ this.addTrace(attributes.title);
|
|
|
+ this.centerAndZoom(e.sourceTarget._latlng.lat, e.sourceTarget._latlng.lng, 9);
|
|
|
|
|
|
- // this.geoJSON.layer = new Layer(polyline(GeoJSON.coordsToLatLngs(g, 1)));
|
|
|
- // console.log(this.geoJSON.layer.options);
|
|
|
- });
|
|
|
- return false;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * ajout d'une trace à la map, dans le tableau de layers
|
|
|
+ *
|
|
|
+ * TODO: reset layer fonctionne mais doit imérativement avoir réussi à charger la trace demandée avant de tout éffacer
|
|
|
+ * autrement la carte se retrouve vide this.resetLayers();
|
|
|
+ * How to refresh automaticaly the map???
|
|
|
+ * this._onResize();
|
|
|
+ * this.geoJSON.layer.addEventParent(geoJSON.);
|
|
|
+ * @param {string} fileName
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
addTrace(fileName: string) {
|
|
|
+
|
|
|
this.vttTraceWs.getTraceFromFile(fileName)
|
|
|
.subscribe(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)));
|
|
|
+ console.log(this.geoJSON.layer.addData(featureCollection.features[0].geometry));
|
|
|
});
|
|
|
- return false;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
centerAndZoom(lat, lng, zoom) {
|
|
|
this.zoom = zoom;
|
|
|
this.center = latLng(lat, lng);
|
|
|
+ this.zoom = 9;
|
|
|
+ this.latitude = lat;
|
|
|
+ this.longitude = lng;
|
|
|
|
|
|
return false;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- addRoute() {
|
|
|
- // create a red polyline from an array of LatLng points
|
|
|
- const route = polyline(this.vttTraceWs.getMockRoute1());
|
|
|
- this.layers.push(route);
|
|
|
- }
|
|
|
-
|
|
|
- addRoute2() {
|
|
|
- this.layers.push(polyline(this.vttTraceWs.getMockRoute2()));
|
|
|
- }
|
|
|
-
|
|
|
- addRoute3() {
|
|
|
- this.layers.push(polyline(this.vttTraceWs.getMockRoute3()));
|
|
|
- }
|
|
|
-
|
|
|
- addRoute4() {
|
|
|
- this.vttTraceWs.getMockRoute4()
|
|
|
- .subscribe(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]);
|
|
|
- // // return featureCollection.features[0].geometry.coordinates[0];
|
|
|
- // resul = GeoJSON.coordsToLatLngs(g, 0);
|
|
|
- this.layers.push(polyline(GeoJSON.coordsToLatLngs(g, 0)));
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- addRoute5() {
|
|
|
- this.vttTraceWs.getMockRoute5()
|
|
|
- .subscribe(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)));
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
addRoute6() {
|
|
@@ -289,6 +222,12 @@ export class VttTraceComponent implements OnInit {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ resetLayers () {
|
|
|
+ console.log('Resetting layers');
|
|
|
+ // console.log(`Here\'s the counter: ${this.counter}`);
|
|
|
+ this.layers = [];
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/* private showRoute() {
|
|
|
this.fitBounds(this.layers.getBounds(), {
|