小编Giu*_*ppe的帖子

使用OpenLayers 4和Angular 5

我正在尝试在Angular 5中使用OpenLayers 4.

基本上我只是想从官方的OpenLayers网站实现QuickStart示例.

到目前为止我做了什么:

  1. npm install ol --save 下载ol包
  2. angular-cli.json将这些行添加到angular-cli.json中.看到这必须在Stackoverflow上的另一个例子上完成.ol.css文件存在.ol.js文件没有.所以我不知道这是正确还是错误的方式,但它显然不起作用.

我的角度项目包括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)

openlayers angular angular5

13
推荐指数
2
解决办法
2万
查看次数

标签 统计

angular ×1

angular5 ×1

openlayers ×1