バックグラウンド
このプロジェクトでは、echartsを使用してマップを描画します。オンラインのタウンシップレベルの管理境界マップには泥棒がほとんどいないため、カスタムマップを描画するにはbigMap + geojson.ioが必要です。詳細については、タウンシップの分類方法を参照してください。町レベルデータのうちechartsを使用して描画するレベルマップJSON。
しかし、2つの不連続マップブロックは、生成にGeoJSONにおけるこの領域のgeometry.type ===ジオメトリコレクションで生成されたマップ内の領域が存在するからである。
しかし、 echartsはこのタイプを扱いません。詳細
echarts \ lib \ coord \ geo \ parseGeoJson.jsの
133行目あたりのソースコードを参照してください。
このコードはgeoJsonを解析することを意味します。
解決
次の関数を変更する必要があります。
約121行のechartsソースコード
function _default(geoJson, nameProperty) {
}
直接コピーして貼り付けます。
function _default(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 Region(
properties[nameProperty || "name"],
geometries,
properties.cp
);
region.properties = properties;
return region;
}
);
}