mirror of
https://github.com/DerTyp7/street-map-typescript.git
synced 2025-10-31 21:57:07 +01:00
added http module (REST)
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
import { Component, OnInit, AfterViewInit } from '@angular/core';
|
||||
import { Component, OnInit, AfterViewInit, NgModule } from '@angular/core';
|
||||
import { defaults as defaultControls } from 'ol/control';
|
||||
import { fromLonLat } from 'ol/proj';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
import Map from 'ol/Map';
|
||||
import View from 'ol/View';
|
||||
import TileLayer from 'ol/layer/Tile';
|
||||
import XYZ from 'ol/source/XYZ';
|
||||
import ZoomToExtent from 'ol/control/ZoomToExtent';
|
||||
import { Nom } from './interfaces/nom';
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -14,12 +21,22 @@ import ZoomToExtent from 'ol/control/ZoomToExtent';
|
||||
styleUrls: ['./app.component.css', '../../node_modules/ol/ol.css']
|
||||
})
|
||||
|
||||
export class AppComponent implements AfterViewInit {
|
||||
export class AppComponent implements AfterViewInit, OnInit {
|
||||
title = "Street Map";
|
||||
map: Map;
|
||||
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
|
||||
getValue(valueFrom:string, valueTo:string){
|
||||
console.log("From " + valueFrom + " to " + valueTo);
|
||||
this.http.get<Nom[]>("https://nominatim.openstreetmap.org/search.php?format=jsonv2&q=" + valueFrom)
|
||||
.subscribe((response: Nom[]) => console.log(response))
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
@@ -33,7 +50,8 @@ export class AppComponent implements AfterViewInit {
|
||||
})
|
||||
],
|
||||
view: new View({
|
||||
center: [813079.7791264898, 5929220.284081122],
|
||||
projection: 'EPSG:3857',
|
||||
center: fromLonLat([8, 52]),
|
||||
zoom: 2
|
||||
}),
|
||||
controls: defaultControls().extend([
|
||||
@@ -45,7 +63,7 @@ export class AppComponent implements AfterViewInit {
|
||||
})
|
||||
])
|
||||
});
|
||||
|
||||
setTimeout(() => this.map.updateSize(), 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user