在 Openlayers 5 中加载 TopoJSON 文件时出错

问题描述

我有一个未正确加载到 openlayers 的有效 TopoJSON 文件(由 Mapshaper 验证)。 topoJSON 是从有效的 GeoJSON 文件中创建的,该文件确实可以正确加载到 OpenLayers 中。

TopoJSON 文件https://github.com/mmosier6/dataquery/blob/main/work/watches_fips_2020.topojson
GeoJSON 文件https://github.com/mmosier6/dataquery/blob/main/work/watches_fips_2020.geojson

function watchMap(){
...
  jQuery.ajax({ 
    url:"data/watches_fips_2020.topojson",dataType: "json"
  }).done(function(data){
    
    vectorSource = new ol.source.Vector({
      features: (new ol.format.TopoJSON({layers:'watches_fips_2020'})).readFeatures(data,{featureProjection: 'epsg:3857',dataProjection:'epsg:4326'})
    });

    var mapData = new ol.layer.Vector({
      source: vectorSource,style: function (feature) {
        return getStyle(feature);
      }
    });     
    map = new ol.Map({
      target: 'map',layers: [new ol.layer.Tile({source: new ol.source.OSM()}),mapData],view: new ol.View({
        center: ol.proj.fromLonLat([-95,38]),zoom: 4
      })
    });
}

控制台返回这些错误

TopoJSON.js:327 Uncaught TypeError: l is not a function
 at Oy (TopoJSON.js:327)
 at My (TopoJSON.js:300)
 at t.readFeaturesFromObject (TopoJSON.js:105)
 at t.e.readFeatures (JSONFeature.js:51)
 at Object.<anonymous> (watchMap.js:24)

我试图通过检查 TopoJSON.js 中的函数来找到错误,但无法弄清楚。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...