无效GeoJSON的错误单张 - 安卓

问题描述:

我与小叶在Android的工作。我想用GeoJSON的与单张..无效GeoJSON的错误单张 - 安卓

传单官方网站是saying,我可以使用无缝的FeatureCollection

就凭这,我试图在单张使用GeoJSON的,但我得到一个错误..

我的错误是“未捕获错误:无效的GeoJSON的对象在文件:///android_asset/www/leaflet.js:8”

这里我以GeoJSON

{ 
    "features": [ 
     { 
      "geometry": { 
       "coordinates": [ 
        [ 
         [ 
          32.54132554492192, 
          38.23922491639042 
         ], 
         [ 
          32.54681870898355, 
          38.161522193191885 
         ], 
         [ 
          32.75967881640627, 
          38.16476146212179 
         ], 
         [ 
          32.68826768359334, 
          38.24030353694492 
         ], 
         [ 
          32.54132554492192, 
          38.23922491639042 
         ] 
        ] 
       ], 
       "type": "Polygon" 
      }, 
      "properties": { 
       "name": "shapeId", 
       "value": "1" 
      }, 
      "type": "Feature" 
     }, 
     { 
      "geometry": { 
       "coordinates": [ 
        [ 
         [ 
          32.21585557421817, 
          38.209017044734495 
         ], 
         [ 
          32.19937608203057, 
          38.11723776214526 
         ], 
         [ 
          32.37927720507808, 
          38.123720089271345 
         ], 
         [ 
          32.32571885546793, 
          38.232752857036594 
         ], 
         [ 
          32.21585557421817, 
          38.209017044734495 
         ] 
        ] 
       ], 
       "type": "Polygon" 
      }, 
      "properties": { 
       "name": "shapeId", 
       "value": "2" 
      }, 
      "type": "Feature" 
     }, 
     { 
      "geometry": { 
       "coordinates": [ 
        [ 
         [ 
          32.55505845507735, 
          38.11507685855403 
         ], 
         [ 
          32.37103745898429, 
          38.07616966143842 
         ], 
         [ 
          32.3943834062496, 
          37.97015072378485 
         ], 
         [ 
          32.677281355468274, 
          37.99721094465765 
         ], 
         [ 
          32.55505845507735, 
          38.11507685855403 
         ] 
        ] 
       ], 
       "type": "Polygon" 
      }, 
      "properties": { 
       "name": "shapeId", 
       "value": "3" 
      }, 
      "type": "Feature" 
     }, 
     { 
      "geometry": { 
       "coordinates": [ 
        32.28452012499983, 
        37.872651327798025 
       ], 
       "type": "Point" 
      }, 
      "properties": { 
       "name": "shapeId", 
       "value": "234" 
      }, 
      "type": "Feature" 
     }, 
     { 
      "geometry": { 
       "coordinates": [ 
        32.25980088671844, 
        37.77719365533954 
       ], 
       "type": "Point" 
      }, 
      "properties": { 
       "name": "shapeId", 
       "value": "235" 
      }, 
      "type": "Feature" 
     } 
    ], 
    "type": "FeatureCollection" 
} 

当我从herehere检查,有大约JSON没有问题..

在Android的侧,我使用这个命令

mAppView.loadUrl("javascript:send('"+tmp+"')"); //tmp is my string which is converted from json 

在JavaScript端

function send(geojsonFeature) 
{ 
alert(geojsonFeature); 

L.geoJson(geojsonFeature).addTo(map); 

} 

我的错误是“未捕获的错误:无效的GeoJSON对象。在文件:///android_asset/www/leaflet.js:8"

,这是leaflet.js

当我尝试添加只是功能,而无需的FeatureCollection,没有错误

有关。例如,如果我设置TMP不喜欢的FeatureCollection这样,错误没有出现

tmp = { 
    "type": "Feature", 
    "properties": { 
     "name": "Coors Field", 
     "amenity": "Baseball Stadium", 
     "popupContent": "This is where the Rockies play!" 
    }, 
    "geometry": { 
     "type": "Point", 
     "coordinates": [-104.99404, 39.75621] 
    } 
}; 

感谢您阅读..有什么建议?

你试试从javascript函数中删除单引号:)