【发布时间】:2019-02-24 23:35:59
【问题描述】:
我尝试将 GeoJson 文件导入 Angular 应用程序 6 中的传单。
使用这个解决方案,我的 geojson 被绘制在小册子地图中,但我有这个错误,我无法构建我的应用程序。有人知道一种解决方案吗?
ERROR TS2345 类型参数 '{"type": string;"features":({"type": 细绳; “几何”:{“类型:字符串:”坐标“:num ...”不是 GeoJsonObject 类型的可赋值参数
模型.ts
export const Pdl = [ 'my geojson' ];
组件.ts
import { LeafletModule } from '@asymmetrik/ngx-leaflet';
import * as L from 'leaflet';
import {Pdl} from "../models/pdl.model";
@Component({
selector: 'app-geo',
templateUrl: './geo.component.html',
styleUrls: ['./geo.component.scss']
})
export class GeoComponent implements OnInit {
ngOnInit() {
var mapboxAccessToken = "...";
const myfrugalmap = L.map('frugalmap').setView([47.482019, -1], 7);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=' + mapboxAccessToken, {
id: 'mapbox.light',
attribution: 'SOS'
}).addTo(myfrugalmap);
L.geoJSON(Pdl).addTo(myfrugalmap);
}
}
也许,我可以隐藏错误?有什么办法?
【问题讨论】:
标签: javascript angular leaflet geojson ngx-leaflet