leaflet加载geoJSON图层数据时报Invalid LatLng object

leaflet加载geoJSON图层数据时报Invalid LatLng object
一、问题leaflet加载geoJSON图层数据时报:Uncaught Error:Invalid LatLng object错误,如下所示
(1)Uncaught Error: Invalid LatLng object: (undefined, undefined)

leaflet加载geoJSON图层数据时报Invalid LatLng object_第1张图片
(2)Uncaught Error: Invalid LatLng object: (121,39, 123,41)

leaflet加载geoJSON图层数据时报Invalid LatLng object_第2张图片
二、经测试排查问题原因为geometry对象中type属性与coordinates属性不一致引起。
(1)报错代码"geometry":{ "type": "MultiPolygon", "coordinates": [[[123,41],[121,39],[126,41]]]}




  
    
    Leaflet Map

    
  
  
    
    


修改为"geometry":{ "type": "MultiPolygon", "coordinates": [[[[123,41],[121,39],[126,41]]]]}后正常




  
    
    Leaflet Map

    
  
  
    
    


(1)报错代码"geometry":{ "type": "Polygon", "coordinates": [[[[123,41],[121,39],[126,41]]]]}




  
    
    Leaflet Map

    
  
  
    
    


修改为"geometry":{ "type": "Polygon", "coordinates": [[[123,41],[121,39],[126,41]]]}后正常




  
    
    Leaflet Map

    
  
  
    
    


三、总结geometry对象中type属性为"MultiPolygon"时coordinates属性为四维数组。geometry对象中type属性为"Polygon"时coordinates属性为三维数组

 

 

你可能感兴趣的:(GIS,JavaScript,leaflet,javascript,leaflet,gis)