0
我與小葉在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"
}
在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]
}
};
感謝您閱讀..有什麼建議?