展示浙江台州的区县时发现页面报错,找了一圈发现文件里不一样的地方就是玉环市JSON里面有一个"type": “GeometryCollection”
修改node_modules\echarts\lib\coord\geo\parseGeoJson.js代码
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Parse and decode geo json
*/
import * as zrUtil from 'zrender/lib/core/util';
import Region from './Region';
function decode(json) {
if (!json.UTF8Encoding) {
return json;
}
var jsonCompressed = json;
var encodeScale = jsonCompressed.UTF8Scale;
if (encodeScale == null) {
encodeScale = 1024;
}
var features = jsonCompressed.features;
for (var f = 0; f < features.length; f++) {
var feature = features[f];
var geometry = feature.geometry;
if (geometry.type === 'Polygon') {
var coordinates = geometry.coordinates;
for (var c = 0; c

这篇博客讲述了在展示浙江台州地图时遇到的页面报错问题,原因是玉环市JSON中的&type:“GeometryCollection”。博主通过修改echarts库的`parseGeoJson.js`文件解决了此问题,主要涉及对GeoJSON的解码和处理,确保了多边形数据的正确解析。修复后,地图能够正常展示。
最低0.47元/天 解锁文章
2700

被折叠的 条评论
为什么被折叠?



