gpt4 book ai didi

javascript - 类型为 'GeoJsonObject' 的 STRING 参数

转载 作者:行者123 更新时间:2023-12-01 01:43:09 26 4
gpt4 key购买 nike

叶子让文档说:

import * as L from 'leaflet';

https://raw.githubusercontent.com/alanent/france-geojson/master/regions/pays-de-la-loire/departements-pays-de-la-loire.geojson

GeoJSON 层GeoJSON 对象通过 GeoJSON 图层添加到 map 中。要创建它并将其添加到 map 中,我们可以使用以下代码:

ngOnInit{
L.GeoJSON(geojsonFeature).addTo(myfrugalmap);
}

The geojson is drawn but i receive an error :

ERROR in src/app/geo/geo.component.ts(335,11): error TS2345: Argument
of type '{ "type": string; "features": ({ "type": string; "geometry":
{ "type": string; "coordinates": num...' is not assignable to
parameter of type 'GeoJsonObject'. Property 'type' is missing in
type '{ "type": string; "features": ({ "type": string; "geometry": {
"type": string; "coordinates": num...'.

我可以忽略这个错误吗?

最佳答案

类型声明中不存在 amenity 和 popupContent

应该是:

import * as L from 'leaflet';

var geojsonFeature = {
"type": "Feature",
"properties": {
"name": "Location B",
"category": "House"
},
"geometry": {
"type": "Point",
"coordinates": [-104.99404, 39.75621]
}
};

ngOnInit{
L.geoJSON(geojsonFeature).addTo(map); // or L.geoJSON([geojsonFeature]).addTo(map);
}

请参阅此处文档 https://www.npmjs.com/package/geojson#readme

关于javascript - 类型为 'GeoJsonObject' 的 STRING 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52220305/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com