当前位置:网站首页>Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind
Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind
2022-07-28 21:22:00 【song854601134】
contrast geojson Data discovery , The reason for the error is that there are GeometryCollection There is . After analysis , Because one area in the generated map is two discontinuous map blocks , So the resulting geoJson In this area geometry.type===GeometryCollection. However ,echarts This type is not handled in , For details, see
Visit the official github Warehouse ,issues There is a corresponding solution , https://github.com/apache/echarts/issues/9350
Two 、 Modification method
If the function is the same , You can directly copy and paste the following paragraph , Other situations , Please refer to the following figure. 2 Modify the logic at the beginning and change it by yourself .
export default function parseGeoJson(geoJson, nameProperty) {
decode(geoJson);
return zrUtil.map(
zrUtil.filter(geoJson.features, function(featureObj) {
if (featureObj.geometry.geometries) {
let geometry = featureObj.geometry.geometries.map(i => {
return i.coordinates;
});
let {
type, properties, ...params } = featureObj;
return {
type, properties, geometry };
}
// Output of mapshaper may have geometry null
return (
featureObj.geometry &&
featureObj.properties &&
featureObj.geometry.coordinates &&
featureObj.geometry.coordinates.length > 0
);
}),
function(featureObj) {
var properties = featureObj.properties;
var geo = featureObj.geometry;
var coordinates = geo.coordinates;
var geometries = [];
if (geo.type === "GeometryCollection") {
let geometry = {
type: "Polygon"
};
let coordinatesArr = featureObj.geometry.geometries.map(i => {
return i.coordinates;
});
geometry.coordinates = coordinatesArr;
console.log(coordinatesArr, "coordinatesArr");
coordinatesArr.forEach(i => {
geometries.push({
type: "polygon",
// According to the GeoJSON specification.
// First must be exterior, and the rest are all interior(holes).
exterior: i[0],
interiors: i.slice(1)
});
});
}
if (geo.type === "Polygon") {
console.log("coordinatesPolygon", coordinates);
geometries.push({
type: "polygon",
// According to the GeoJSON specification.
// First must be exterior, and the rest are all interior(holes).
exterior: coordinates[0],
interiors: coordinates.slice(1)
});
}
if (geo.type === "MultiPolygon") {
zrUtil.each(coordinates, function(item) {
if (item[0]) {
geometries.push({
type: "polygon",
exterior: item[0],
interiors: item.slice(1)
});
}
});
}
console.log(
properties[nameProperty || "name"],
geometries,
properties.cp,
"asdfasdfasdf"
);
var region = new GeoJSONRegion(
properties[nameProperty || "name"],
geometries,
properties.cp
);
region.properties = properties;
return region;
}
);
}
What needs to be revised parseGeoJson Function 2 It's about :echarts The source code in 116 Row or so
边栏推荐
- 移动端空余部位自动填充
- 学习Typescript(二)
- ctfshow 网络迷踪做题记录(2)
- Unity - Fundamentals of 3D mathematics
- Study and use of cobalt strike
- (PMIC)全、半桥驱动器CSD95481RWJ PDF 规格
- quii cordova-plugin-telerik-imagepicker插件多图上传乱序
- Invalid prompt object name in SQL Server
- C # detailed steps for connecting to MySQL database
- The development of smart home industry pays close attention to edge computing and applet container technology
猜你喜欢

小程序容器技术,让移动研发效率提升500%

什么是 CI/CD? | 实现更快更好的软件交付

Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind

Nacos principle

High salary in the workplace | "intermediate and advanced test" interview questions

Analysis of critical path

There have been two safety accidents in a month after listing. Is L9 ideal?

Redis cache avalanche, cache penetration, cache breakdown

Unity - Fundamentals of 3D mathematics

BUUCTF做题Upload-Labs记录pass-11~pass-20
随机推荐
Backup and recovery of SQL Server database
小程序容器技术,让移动研发效率提升500%
SSM use @async and create threadpooltaskexecutor thread pool
Basic operations of unity3d scene production
Cobal Strike的学习与使用
(PMIC)全、半桥驱动器CSD95481RWJ PDF 规格
Attribute based encryption simulation and code implementation (cp-abe) paper: ciphertext policy attribute based encryption
Guanghetong & Qualcomm Internet of things technology open day successfully held
DELTA热金属检测器维修V5G-JC-R1激光测量传感器/检测仪原理分析
Moco V2: further upgrade of Moco series
Study - Summary of geometric calculations
Two excellent software of my love cracking, batch search text, image and video image quality enhancement
详细讲解C语言12(C语言系列)
BUUCTF做题Upload-Labs记录pass-11~pass-20
ABB电磁流量计维修信号变送器维修41F/E4技术参数
实习日记第一周
Several skills of API interface optimization
[tidb] importing TXT documents into the database is really efficient
How does lazada store make up orders efficiently? (detailed technical explanation of evaluation self-supporting number)
What is ci/cd| Achieve faster and better software delivery
