“ GeoJsonObject”类型的STRING参数

时间:2018-09-07 10:10:36

标签: javascript angular leaflet geojson

叶子让文档说:

function is_prime($p) {

    $r1 = $p%2;
    $r2 = $p%3;
    $r3 = $p%5;

    return ($p > 1) &&  (($r1 >= 1) && ($r2 >= 1) && ($r3 >= 1)) ||  in_array($p, [2,3,5]);
}

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

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

import * as L from 'leaflet';
  

绘制了geojson,但是我收到一个错误消息:

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

我可以忽略此错误吗?

1 个答案:

答案 0 :(得分:2)

便利设施和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