我正在尝试在Angular 5中使用OpenLayers 4.
基本上我只是想从官方的OpenLayers网站实现QuickStart示例.
到目前为止我做了什么:
npm install ol --save 下载ol包我的角度项目包括3个组件:
-app
--console
--map
--sidebar
app.component.css
app.compinent.html
app.component.spec.ts
app.component.ts
app.module.ts
Run Code Online (Sandbox Code Playgroud)
map.component.html
import { Component, OnInit } from '@angular/core';
import * as ol from '../../../node_modules/ol';
@Component({
selector: 'app-map',
templateUrl: './map.component.html',
styleUrls: ['./map.component.css']
})
export class MapComponent implements OnInit {
mapId: string;
map: ol.Map = undefined;
constructor() { }
ngOnInit() {
this.map = new ol.Map({
target: this.mapId,
layers: [
new ol.layer.Tile({
source: new ol.source.OSM(),
}),
],
view: new …Run Code Online (Sandbox Code Playgroud)