diff --git a/src/app/app.component.html b/src/app/app.component.html index 3714cce..cc47a56 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,7 +1,7 @@
- - + +

{{title}}

diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 0543b87..3f46199 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -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("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); } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0a062ae..1be550e 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,6 +1,6 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; - +import {HttpClientModule} from '@angular/common/http'; import { AppComponent } from './app.component'; @NgModule({ @@ -8,7 +8,8 @@ import { AppComponent } from './app.component'; AppComponent, ], imports: [ - BrowserModule + BrowserModule, + HttpClientModule ], providers: [], bootstrap: [AppComponent] diff --git a/src/app/interfaces/nom.ts b/src/app/interfaces/nom.ts new file mode 100644 index 0000000..6b5e6ab --- /dev/null +++ b/src/app/interfaces/nom.ts @@ -0,0 +1,4 @@ + +export interface Nom { + boundingbox: Array; +}