问题描述
我有一个传单地图,在其中添加了FeatureCollection
以及由voronoi
(docs)的turfjs
函数产生的一些多边形。现在,我尝试用代表国家的Multipolygon
与这些多边形相交,以便Voronoi多边形仅在该国家内部显示。对于路口,我使用的是martinez。
Voronoi多边形:
var voronoipolygons = turf.voronoi(poll1); //Creating the polygons
voronoipolygons.features.map((f,i) => {
f.properties = poll1.features[i].properties; //Adding the original properties to the new polygons
});
与国家边界的交点:
voronoipolygons.features.forEach(trimBorder);
function trimBorder(value,index,array){
//Intersection using Martinez,returns set of coordinates
let newpolygon = martinez.intersection(value.geometry.coordinates,borderPT.geometry.coordinates);
//Change the feature type to Multipolygon if the intersection generates a Multipolygon
voronoipolygons.features[index].geometry.coordinates = newpolygon;
if (newpolygon.length > 1) voronoipolygons.features[index].geometry.type = "Multipolygon";
}
但是,当我运行它时,出现以下错误:
Uncaught Error: Invalid LatLng object: (-8.395214820999854,37.08713944100005,-8.395575540353551,37.08710300941793)
at new D (LatLng.js:32)
at We (GeoJSON.js:235)
at He (GeoJSON.js:248)
at He (GeoJSON.js:247)
at De (GeoJSON.js:203)
at i.addData (GeoJSON.js:117)
at i.addData (GeoJSON.js:107)
at initialize (GeoJSON.js:92)
at new i (Class.js:22)
at Object.Ke (GeoJSON.js:439)
据我了解,该对象中不应有2套坐标。是什么原因造成的?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)