如何在传单地图中修复无效的LatLng对象:(NaN,NaN)?

时间:2019-05-13 21:00:14

标签: javascript json leaflet

我正在尝试使用来自geoJson文件的数据绘制多边形,但出现此错误:

Error: Invalid LatLng object: (NaN, NaN)

这是我的代码:

const latLngs = L.GeoJSON.coordsToLatLngs(data,2);
var polygon = L.polygon(latLngs, {color: 'red'}).addTo(map);
map.fitBounds(polygon.getBounds());

数据:

[[[2.96361,36.802216],[2.981389,36.806938],[3.001111,36.809715],[3.024167,36.808052],[3.031389,36.806389],[3.042222,36.800552],[3.056389,36.79055],[3.068611,36.779716],[3.089166,36.75],[3.106389,36.741943],[3.123055,36.739441],[3.138333,36.738327],[3.172222,36.741386],[3.185553,36.742775],[3.228055,36.77861],[3.307222,36.783051],[3.375833,36.77166],[3.391111,36.770828],[3.472777,36.766937],[3.485555,36.769165],[3.544167,36.785553],[3.625,36.810555],[3.645833,36.820549],[3.651667,36.823608],[3.665833,36.831108],[3.685277,36.842773],[3.698333,36.853333],[3.701944,36.857498],[3.711667,36.871941],[3.720833,36.878052],[3.742222,36.887215],[3.753611,36.891106],[3.815833,36.903328],[3.891666,36.917221],[3.899444,36.916664],[3.905555,36.914162],[3.91,36.910828],[3.922222,36.899719],[3.924444,36.895271],[3.929722,36.89222],[3.937222,36.890274],[3.952222,36.888054],[3.965555,36.88916],[3.997498,36.894722],[4.076111,36.885551],[4.106111,36.884163],[4.245277,36.903328],[4.294999,36.904442],[4.389444,36.895271],[4.550555,36.884163],[4.564444,36.88472],[4.603357,36.887909],[4.635555,36.886383],[4.699166,36.886108],[4.720833,36.886108],[4.728055,36.886383],[4.740555,36.888329],[4.758333,36.893051],[4.785832,36.894722],[4.791666,36.893051],[4.923333,36.846939],[5.096944,36.777771],[5.102221,36.774994],[5.1025,36.769165],[5.100277,36.763329],[5.083129,36.738838],[5.079721,36.73555],[5.077777,36.730827],[5.078055,36.725273],[5.080277,36.720833],[5.086944,36.712494],[5.09111,36.70916],[5.106944,36.699997],[5.156111,36.674995],[5.167777,36.669716],[5.195,36.660828],[5.236944,36.648048],[5.244166,36.646111],[5.2525,36.644722],[5.299444,36.640274],[5.328055,36.640274],[5.424444,36.653053],[5.436501,36.665321],[5.459444,36.66333],[5.465833,36.664162],[5.529166,36.692497],[5.53361,36.695831],[5.547777,36.713608],[5.560277,36.733887],[5.567222,36.743332],[5.581388,36.761108],[5.590278,36.767776],[5.600277,36.773048],[5.699166,36.819717],[5.709999,36.824165],[5.739444,36.832222],[5.745555,36.833328],[5.76611,36.834717],[5.774444,36.833054],[5.779722,36.830276],[5.787222,36.822495],[5.793611,36.82],[5.811944,36.813332],[5.819444,36.812775],[5.866944,36.816383],[6,36.837776],[6.018611,36.84166],[6.03,36.845276],[6.164444,36.89222],[6.233333,36.913605],[6.237778,36.916939],[6.246666,36.923882],[6.263055,36.946106],[6.264722,36.951385],[6.259999,36.96611],[6.257777,36.970833],[6.249166,36.97805],[6.248055,36.983055],[6.268332,37.018608],[6.272778,37.021942],[6.361666,37.080276],[6.372222,37.083328],[6.398333,37.086388],[6.464722,37.091385],[6.478611,37.088333],[6.49861,37.081383],[6.509166,37.075272],[6.518055,37.069443],[6.526667,37.062218],[6.541944,37.044998],[6.57361,37.008331],[6.571111,37.002495],[6.572499,36.997498],[6.58,36.984161],[6.583333,36.979996],[6.592777,36.97361],[6.912777,36.884995],[6.928055,36.883606],[6.95,36.883331],[6.962777,36.884995],[7.135278,36.910271],[7.147499,36.913055],[7.170555,36.919998],[7.220555,36.954163],[7.229722,36.961105],[7.245,36.977776],[7.255833,36.991104],[7.258611,37.003883],[7.2575,37.009163],[7.248888,37.027496],[7.225555,37.038887],[7.215278,37.044998],[7.207222,37.051109],[7.198889,37.058327],[7.183055,37.073326],[7.1825,37.077499],[7.186944,37.080826],[7.206111,37.083611],[7.229722,37.086388],[7.248055,37.079437],[7.259444,37.073883],[7.269994,37.067776],[7.289444,37.077499],[7.295555,37.076942],[7.463611,37.042496],[7.553888,37.004997],[7.573333,36.993332],[7.593611,36.982498],[7.611388,36.976387],[7.618055,36.974998],[7.729722,36.966385],[7.7575,36.965553],[7.765277,36.966385],[7.772499,36.927773],[7.773053,36.879719],[7.777222,36.876389],[7.792222,36.86805],[7.809999,36.861938],[7.822778,36.858604],[7.876666,36.847496],[7.932221,36.844444],[7.948333,36.844994],[7.961111,36.848328],[8.0425,36.871384],[8.060276,36.878052],[8.160276,36.921944],[8.213055,36.948051],[8.223331,36.953331],[8.229166,36.955276],[8.236944,36.954437],[8.390276,36.918884],[8.545832,36.921387],[8.62203,36.941368],[8.632221,36.881943],[8.638054,36.831108],[8.476387,36.743607],[8.47611,36.723328],[8.475277,36.717216],[8.458611,36.669441],[8.455832,36.664719],[8.447498,36.657219],[8.438055,36.651939],[8.352221,36.60527],[8.347221,36.602776],[8.250832,36.571663],[8.231388,36.567215],[8.215277,36.560555],[8.199999,36.551666],[8.193888,36.54361],[8.185555,36.529442],[8.183611,36.524162],[8.181944,36.51194],[8.181665,36.505272],[8.183332,36.499161],[8.186666,36.494995],[8.195833,36.488884],[8.215277,36.483887],[8.237778,36.481941],[8.253887,36.48111],[8.277498,36.481384],[8.285,36.482773],[8.293333,36.482773],[8.306944,36.479996],[8.365555,36.45916],[8.36972,36.455551],[8.372221,36.450829],[8.37361,36.444717],[8.37611,36.426666],[8.376665,36.413605],[8.374443,36.374992],[8.371666,36.357498],[8.336388,36.296104],[8.331388,36.286659],[8.319443,36.214439],[8.319166,36.195549],[8.305277,36.097496],[8.290833,36],[8.282973,35.965313],[8.280277,35.961937],[8.268888,35.930275],[8.264444,35.91333],[8.260555,35.856384],[8.261665,35.822495],[8.263332,35.811104],[8.26861,35.775833],[8.273611,35.758606],[8.277498,35.749161],[8.280832,35.743889],[8.294998,35.728607],[8.302221,35.721939],[8.323889,35.70472],[8.333611,35.692497],[8.336111,35.687775],[8.340277,35.677498],[8.341665,35.671944],[8.344166,35.65361],[8.345554,35.63472],[8.345276,35.623604],[8.348888,35.584442],[8.322222,35.457771],[8.314722,35.44416],[8.309444,35.427216],[8.304165,35.404999],[8.301388,35.392776],[8.301388,35.379997],[8.302776,35.367775],[8.308332,35.339165],[8.316387,35.317215],[8.322222,35.308327],[8.336111,35.293327],[8.344999,35.287216],[8.40111,35.192215],[8.338888,35.121384],[8.328609,35.109444],[8.326111,35.104721],[8.324444,35.099159],[8.28611,34.965553],[8.273333,34.851662],[8.277222,34.834442],[8.290277,34.758331],[8.28861,34.752777],[8.28611,34.748886],[8.276943,34.742775],[8.270155,34.740105],[8.265276,34.738052],[8.245277,34.720551],[8.241943,34.71666],[8.229166,34.700272],[8.224998,34.690277],[8.224998,34.683884],[8.232222,34.675827],[8.244444,34.666107],[8.250277,34.662773],[8.253611,34.659164],[8.255278,34.654442],[8.251665,34.64444],[8.123333,34.539162],[8.118332,34.536659],[8.106552,34.532722],[8.070276,34.521942],[8.03611,34.509163],[7.868889,34.436104],[7.850555,34.423332],[7.839722,34.412498],[7.825555,34.389442],[7.823055,34.378326],[7.822778,34.366104],[7.824444,34.346382],[7.819444,34.330826],[7.786666,34.254715],[7.784166,34.250549],[7.777499,34.242493],[7.7675,34.236382],[7.751111,34.230553],[7.731111,34.226387],[7.701666,34.223885],[7.681666,34.219994],[7.656944,34.212494],[7.641388,34.204994],[7.632222,34.199715],[7.619721,34.189438],[7.530555,34.106667],[7.527222,34.101944],[7.518055,34.083054],[7.51526,34.071915],[7.518611,34.01416],[7.517777,33.994438],[7.508611,33.967773],[7.502777,33.952217],[7.497777,33.942772],[7.492777,33.926384],[7.491666,33.91333],[7.492499,33.887497],[7.514999,33.810555],[7.55611,33.678604],[7.558611,33.673882],[7.675555,33.507774],[7.725027,33.419403],[7.724722,33.399162],[7.724444,33.373055],[7.724166,33.318604],[7.726388,33.286659],[7.731944,33.248329],[7.743055,33.229164],[7.752777,33.218887],[7.756944,33.214722],[7.764999,33.208611],[7.775555,33.204437],[8.016109,33.114998],[8.022778,33.112778],[8.041388,33.108055],[8.049444,33.107216],[8.072222,33.109161],[8.078888,33.11055],[8.090277,33.114441],[8.157776,33.028053],[8.274166,32.876663],[8.30611,32.83416],[8.312222,32.793053],[8.319443,32.738327],[8.323332,32.710274],[8.342777,32.573608],[8.34861,32.533333],[8.350983,32.531219],[8.415277,32.491661],[8.559999,32.40416],[8.688332,32.326111],[8.864443,32.218048],[9.008333,32.12944],[9.055277,32.099998],[9.059166,32.09111],[9.08256,32.00008],[9.105833,31.912777],[9.181389,31.624165],[9.213333,31.500553],[9.298611,31.170555],[9.334166,31.032776],[9.38361,30.840275],[9.436388,30.633888],[9.468054,30.509998],[9.520555,30.303333],[9.534166,30.248333],[9.537113,30.23439],[9.511389,30.222775],[9.382776,30.162498],[9.318888,30.131943],[9.303888,30.122498],[9.314999,30.105274],[9.322777,30.096664],[9.345554,30.076664],[9.362499,30.063332],[9.385832,30.0425],[9.402222,30.021664],[9.413609,30.003889],[9.449165,29.965832],[9.551388,29.827774],[9.566666,29.806942],[9.578888,29.789165],[9.638054,29.691109],[9.66111,29.649166],[9.680832,29.611664],[9.724998,29.521385],[9.757221,29.454166],[9.764721,29.433331],[9.766388,29.427776],[9.829721,29.19833],[9.839722,29.16],[9.847221,29.11861],[9.852221,29.089722],[9.85611,29.066109],[9.865276,28.993053],[9.869444,28.949997],[9.873333,28.859165],[9.873055,28.839996],[9.871666,28.80611],[9.867498,28.768055],[9.859444,28.708885],[9.846834,28.630436],[9.838055,28.571941],[9.812222,28.407776],[9.798332,28.325554],[9.790277,28.270554],[9.789721,28.256664],[9.794722,28.242496],[9.830555,28.159721],[9.842499,28.131943],[9.901388,27.993332],[9.954166,27.86861],[9.957499,27.853054],[9.954166,27.839443],[9.948332,27.824444],[9.890276,27.648609],[9.881109,27.621109],[9.875832,27.607498],[9.86861,27.603054],[9.819166,27.537777],[9.776388,27.439163],[9.734999,27.323887],[9.733889,27.316944],[9.734444,27.311665],[9.741943,27.25972],[9.745277,27.25],[9.802776,27.097775],[9.818054,27.056389],[9.829166,27.005276],[9.848331,26.908607],[9.900276,26.878609],[9.916388,26.870831],[9.930555,26.859722],[9.919722,26.804722],[9.912777,26.777496],[9.895832,26.695553],[9.916943,26.673332],[9.899166,26.609997],[9.871666,26.514164],[9.762777,26.468609],[9.668888,26.429722],[9.499443,26.357498],[9.442221,26.270275],[9.400276,26.204998],[9.396111,26.194721],[9.393055,26.182777],[9.393888,26.170555],[9.398333,26.153332],[9.435276,26.104721],[9.479443,26.048885],[9.791666,25.644722],[9.85611,25.560833],[10.005554,25.365555],[10.026667,25.337498],[10.037498,25.321388],[10.039165,25.279442],[10.045277,25.087498],[10.047777,25.005276],[10.049721,24.936386],[10.050833,24.867775],[10.054443,24.838055],[10.134769,24.795635],[10.174166,24.774998],[10.218332,24.75111],[10.227499,24.71611],[10.230833,24.702221],[10.24,24.66],[10.252222,24.605831],[10.303333,24.566666],[10.406944,24.488609],[10.422222,24.478054],[10.48,24.478054],[10.576666,24.515553],[10.668055,24.550278],[10.715277,24.567219],[10.756943,24.550552],[10.832499,24.520275],[10.969688,24.472363],[11.012894,24.457829],[11.110832,24.429722],[11.275276,24.383053],[11.349998,24.362499],[11.439444,24.336941],[11.469559,24.327515],[11.558887,24.302498],[11.726017,24],[11.757221,23.941666],[11.918888,23.647499],[11.986475,23.522305],[11.768332,23.398052],[11.707499,23.364166],[11.100555,23.016941],[10.828333,22.859997],[10.752777,22.816387],[10.616943,22.737778],[10.340244,22.576477],[10.120277,22.447777],[9.742867,22.226391],[9.469872,22.065186],[8.99861,21.785],[8.71611,21.615833],[8.582499,21.535553],[8.049444,21.213333],[7.916666,21.1325],[7.724999,21.015553],[7.651388,20.970554],[7.636666,20.960831],[7.472147,20.860386],[7.459999,20.853054],[7.450807,20.852863],[6.930277,20.408333],[6.644722,20.164444],[6.473888,20.017776],[6.303333,19.871109],[5.981667,19.59333],[5.963611,19.576942],[5.812499,19.44611],[5.785277,19.440277],[5.656944,19.416111],[5.546944,19.396111],[5.308611,19.35083],[4.886944,19.269722],[4.502222,19.195553],[4.355833,19.167221],[4.245277,19.146664],[4.080832,19.116665],[3.952777,19.093052],[3.909098,19.084814],[3.733333,19.051666],[3.331944,18.976387],[3.183888,19.078609],[3.140833,19.113609],[3.133889,19.120552],[3.118611,19.140274],[3.116666,19.145275],[3.114166,19.156387],[3.125833,19.179996],[3.146389,19.201942],[3.191111,19.256107],[3.269166,19.369442],[3.274722,19.37833],[3.277222,19.389721],[3.278333,19.402775],[3.277778,19.408886],[3.276667,19.414444],[3.2725,19.424164],[3.269722,19.428608],[3.262777,19.435555],[3.254444,19.441387],[3.249444,19.443607],[3.245833,19.446941],[3.243889,19.451942],[3.213055,19.548054],[3.21,19.565277],[3.210556,19.579166],[3.214444,19.589165],[3.223055,19.623333],[3.230833,19.737499],[3.235555,19.809444],[3.235,19.815552],[3.233055,19.820274],[3.228611,19.82333],[3.028611,19.917774],[3.013611,19.924442],[2.998611,19.93111],[2.902222,19.966942],[2.711667,20.00222],[2.693611,20.002777],[2.587778,20.001663],[2.520555,20.020554],[2.509166,20.023888],[2.421667,20.053055],[2.411666,20.057499],[2.408055,20.060833],[2.405278,20.064999],[2.398611,20.078888],[2.386389,20.108887],[2.376667,20.126942],[2.355278,20.16111],[2.344166,20.177776],[2.32,20.203053],[2.2825,20.236385],[2.271111,20.246109],[2.266944,20.249165],[2.2275,20.274166],[2.213055,20.281387],[2.194167,20.284721],[2.178055,20.279442],[2.169722,20.273609],[2.129167,20.236385],[2.1025,20.220833],[2.0975,20.218887],[2.085,20.21722],[2.078333,20.218052],[1.900278,20.25972],[1.810278,20.301109],[1.795833,20.308331],[1.783611,20.317497],[1.715,20.369999],[1.671667,20.405277],[1.668056,20.408607],[1.666111,20.413609],[1.665555,20.41972],[1.666389,20.424442],[1.669722,20.439442],[1.671667,20.457222],[1.672222,20.472221],[1.663055,20.53611],[1.660278,20.540276],[1.6275,20.57111],[1.582222,20.597775],[1.573611,20.601944],[1.518889,20.626663],[1.478333,20.641388],[1.351389,20.681942],[1.178889,20.732777],[1.173889,20.734722],[1.1675,20.741108],[1.163889,20.75],[1.161389,20.761108],[1.160833,20.76722],[1.16,20.793331],[1.160555,20.806942],[1.168333,20.834164],[1.170833,20.838886],[1.175555,20.855],[1.181389,20.877499],[1.186389,20.900555],[1.1925,20.937496],[1.197148,21.00248],[1.195555,21.019997],[1.194167,21.025555],[1.185555,21.057777],[1.171944,21.099163],[1.169662,21.102543],[0.768333,21.351665],[0.401111,21.578331],[0.267222,21.660831],[0.149722,21.733055],[0.015556,21.815277],[-0.008056,21.830555],[-0.1075,21.900555],[-0.423333,22.11972],[-0.773889,22.361111],[-1.142778,22.612778],[-1.412222,22.795555],[-1.750556,23.023331],[-2.09,23.25],[-2.448334,23.487221],[-2.824985,23.734722],[-3.233775,24.000534],[-3.462778,24.148888],[-3.792222,24.360275],[-4.123056,24.57111],[-4.525278,24.824997],[-4.806111,25.000275],[-4.813056,25.005833],[-4.883612,25.049721],[-4.918889,25.070831],[-5.289445,25.299999],[-5.641668,25.514788],[-5.821945,25.624722],[-5.857779,25.645554],[-6.286112,25.904442],[-6.304167,25.914444],[-6.662778,26.129166],[-6.771111,26.192497],[-6.986945,26.320831],[-7.203889,26.448608],[-7.258334,26.479721],[-7.693611,26.734165],[-7.711945,26.743889],[-8.131111,26.986385],[-8.204445,27.027496],[-8.644167,27.278889],[-8.66679,27.290459],[-8.667223,27.499443],[-8.667223,27.59972],[-8.666668,27.666664],[-8.667223,27.933331],[-8.667223,28.709442],[-8.628334,28.732777],[-8.581112,28.75861],[-8.575834,28.761108],[-8.555557,28.769722],[-8.521112,28.779442],[-8.495556,28.790554],[-8.412224,28.8475],[-8.40889,28.851387],[-8.400278,28.865276],[-8.393057,28.880554],[-8.38028,28.897499],[-8.369722,28.909164],[-8.361946,28.916111],[-8.3575,28.919167],[-8.200001,29.026665],[-8.176945,29.040833],[-8.167778,29.046108],[-8.152779,29.053333],[-8.137222,29.059719],[-7.986945,29.122776],[-7.798056,29.256107],[-7.690278,29.34111],[-7.668612,29.364166],[-7.657223,29.374996],[-7.644723,29.384998],[-7.64,29.387218],[-7.6225,29.391941],[-7.603333,29.394722],[-7.589723,29.395554],[-7.560556,29.393608],[-7.539445,29.389721],[-7.518333,29.387218],[-7.487779,29.385277],[-7.461945,29.388611],[-7.43889,29.394997],[-7.433889,29.397221],[-7.356389,29.461666],[-7.336112,29.486385],[-7.321667,29.509163],[-7.319445,29.514442],[-7.313056,29.523052],[-7.298334,29.53833],[-7.293889,29.541386],[-7.195001,29.597775],[-7.128612,29.63472],[-7.123889,29.636944],[-7.112223,29.640274],[-7.097778,29.640274],[-6.840834,29.612221],[-6.792223,29.605],[-6.778334,29.602219],[-6.745001,29.594444],[-6.732779,29.590553],[-6.728333,29.587219],[-6.723056,29.584721],[-6.700556,29.575832],[-6.693334,29.574444],[-6.635556,29.566109],[-6.592501,29.566387],[-6.585834,29.567219],[-6.580001,29.568607],[-6.575278,29.57111],[-6.554167,29.586941],[-6.531389,29.609165],[-6.524167,29.616665],[-6.513889,29.628887],[-6.508612,29.638885],[-6.498056,29.666386],[-6.496667,29.672497],[-6.482223,29.736111],[-6.481112,29.743053],[-6.400278,29.804443],[-6.231668,29.798885],[-6.217223,29.798885],[-6.205001,29.801109],[-6.200001,29.803608],[-6.191112,29.809719],[-6.184445,29.818607],[-6.166667,29.838333],[-6.157223,29.844444],[-6.145834,29.8475],[-6.132778,29.848888],[-6.111112,29.848888],[-6.088889,29.848331],[-6.081112,29.8475],[-6.066945,29.844719],[-6.060834,29.842777],[-6.045279,29.834999],[-6.032778,29.831108],[-6.002778,29.829441],[-5.983056,29.831665],[-5.946945,29.839165],[-5.935556,29.84222],[-5.898324,29.856668],[-5.790556,29.876389],[-5.733334,29.88472],[-5.694445,29.889164],[-5.627501,29.894165],[-5.58349,29.895914],[-5.574445,29.894997],[-5.56,29.894997],[-5.538334,29.902496],[-5.523056,29.909443],[-5.390834,29.976387],[-5.351945,29.997219],[-5.343056,30.00333],[-5.313612,30.025833],[-5.275834,30.055275],[-5.223056,30.107498],[-5.170834,30.160275],[-5.152135,30.18047],[-5.144723,30.186665],[-5.133612,30.198055],[-5.085556,30.255554],[-5.076389,30.269165],[-5.048056,30.316666],[-5.029167,30.359165],[-5.010834,30.393887],[-4.994445,30.423611],[-4.974723,30.456944],[-4.964723,30.469719],[-4.942223,30.492222],[-4.934167,30.498886],[-4.920556,30.508053],[-4.909722,30.511665],[-4.639167,30.60083],[-4.467778,30.631664],[-4.43,30.637218],[-4.402223,30.646111],[-4.396945,30.648331],[-4.378889,30.660275],[-4.360001,30.679165],[-4.342223,30.69083],[-4.3325,30.69611],[-4.261111,30.727776],[-4.231668,30.734997],[-4.216111,30.741665],[-4.206389,30.746944],[-4.169168,30.769165],[-4.160833,30.775833],[-4.149445,30.786942],[-4.134167,30.802219],[-4.13139,30.806664],[-4.039445,30.896385],[-4.027223,30.906666],[-4.016945,30.91111],[-3.999167,30.915554],[-3.9875,30.918331],[-3.925278,30.928608],[-3.88,30.934166],[-3.840556,30.938053],[-3.800278,30.941109],[-3.7575,30.941109],[-3.743056,30.94083],[-3.718889,30.938053],[-3.707222,30.94083],[-3.696389,30.944443],[-3.646667,30.961109],[-3.626667,30.970554],[-3.617778,30.976665],[-3.602222,30.991386],[-3.594445,31.014999],[-3.5925,31.02861],[-3.592223,31.034721],[-3.598056,31.086109],[-3.602222,31.095554],[-3.697778,31.150276],[-3.774445,31.156666],[-3.788889,31.148609],[-3.794723,31.147221],[-3.808333,31.148052],[-3.818889,31.153332],[-3.823611,31.159443],[-3.826111,31.163887],[-3.826945,31.16972],[-3.825556,31.182777],[-3.803889,31.339165],[-3.8175,31.441944],[-3.827778,31.453609],[-3.830556,31.458054],[-3.840834,31.47583],[-3.843334,31.486664],[-3.843889,31.498333],[-3.835,31.650276],[-3.830833,31.677498],[-3.825834,31.688053],[-3.818334,31.695553],[-3.808611,31.700554],[-3.7975,31.704166],[-3.785278,31.706944],[-3.721111,31.715832],[-3.714723,31.716389],[-3.685278,31.715832],[-3.663056,31.711941],[-3.656945,31.709999],[-3.650834,31.707775],[-3.646389,31.704441],[-3.630556,31.696388],[-3.569167,31.682499],[-3.547778,31.678055],[-3.526389,31.673611],[-3.518611,31.672775],[-3.511667,31.673332],[-3.481389,31.679443],[-3.42,31.707775],[-3.386114,31.726107],[-3.2875,31.74472],[-3.234723,31.758053],[-3.159722,31.778332],[-3.096945,31.796665],[-2.999444,31.833332],[-2.980556,31.844166],[-2.972222,31.85083],[-2.959445,31.868889],[-2.951389,31.89222],[-2.948611,31.904999],[-2.945834,31.93111],[-2.946945,31.948608],[-2.948611,31.959999],[-2.948334,31.96611],[-2.944445,32.005272],[-2.9425,32.017494],[-2.938056,32.028885],[-2.930833,32.036942],[-2.9075,32.059998],[-2.894444,32.069443],[-2.89,32.072495],[-2.865,32.084717],[-2.853889,32.088333],[-2.463889,32.143608],[-2.417778,32.149162],[-2.345278,32.156944],[-2.331111,32.157494],[-2.3025,32.157219],[-2.264167,32.154716],[-2.166389,32.146111],[-2.135,32.143051],[-2.106389,32.136665],[-2.098333,32.135551],[-1.982778,32.124718],[-1.931111,32.121109],[-1.901667,32.119995],[-1.659445,32.111107],[-1.4925,32.107773],[-1.4725,32.109444],[-1.320278,32.101387],[-1.304167,32.099442],[-1.297222,32.097771],[-1.286667,32.092216],[-1.280556,32.089996],[-1.259167,32.085274],[-1.238611,32.085831],[-1.213056,32.089722],[-1.2025,32.093887],[-1.188611,32.102493],[-1.180556,32.11055],[-1.1775,32.114998],[-1.175556,32.120827],[-1.173889,32.133888],[-1.178056,32.143608],[-1.200834,32.170273],[-1.2125,32.175278],[-1.241667,32.16777],[-1.262222,32.158607],[-1.273611,32.155273],[-1.280278,32.154716],[-1.287222,32.156387],[-1.2925,32.159164],[-1.295833,32.163055],[-1.293415,32.172726],[-1.29,32.177498],[-1.257725,32.208023],[-1.258056,32.240829],[-1.251111,32.32],[-1.249722,32.326942],[-1.220834,32.375832],[-1.211111,32.38916],[-1.203889,32.397499],[-1.196111,32.404716],[-1.186111,32.409721],[-1.18,32.410828],[-1.166111,32.41111],[-1.150556,32.409996],[-1.143889,32.410553],[-1.12,32.41555],[-1.115278,32.418327],[-1.063889,32.449997],[-1.040278,32.471939],[-1.015,32.500549],[-1.011667,32.504997],[-1.010278,32.508331],[-1.266945,32.667221],[-1.382778,32.724442],[-1.5425,32.939438],[-1.493056,32.969444],[-1.487222,32.979164],[-1.482222,32.989441],[-1.478333,33.009995],[-1.476667,33.02916],[-1.476389,33.035271],[-1.4775,33.046661],[-1.478889,33.058052],[-1.480278,33.063049],[-1.482778,33.067497],[-1.486389,33.071388],[-1.495833,33.077499],[-1.517222,33.088608],[-1.548889,33.111382],[-1.580556,33.145828],[-1.646111,33.226387],[-1.665278,33.25666],[-1.668056,33.261108],[-1.669722,33.357216],[-1.668056,33.376389],[-1.666667,33.383331],[-1.664722,33.38916],[-1.648889,33.412216],[-1.633056,33.435272],[-1.625278,33.451111],[-1.600556,33.50972],[-1.599167,33.522774],[-1.600278,33.556938],[-1.601111,33.562492],[-1.604445,33.584442],[-1.606667,33.595276],[-1.641667,33.650833],[-1.652222,33.662773],[-1.656389,33.666107],[-1.667222,33.671387],[-1.688889,33.676384],[-1.701389,33.68055],[-1.718611,33.688332],[-1.726389,33.695549],[-1.729511,33.70153],[-1.730556,33.704994],[-1.730278,33.711388],[-1.710278,33.8825],[-1.706389,33.899162],[-1.6875,33.966385],[-1.654444,34.083611],[-1.658334,34.099998],[-1.719167,34.266663],[-1.750556,34.349442],[-1.793334,34.378326],[-1.7325,34.440277],[-1.686711,34.485512],[-1.690834,34.488609],[-1.696389,34.491104],[-1.716944,34.496666],[-1.732778,34.499161],[-1.738056,34.501938],[-1.7425,34.505272],[-1.853056,34.600555],[-1.856667,34.604439],[-1.8575,34.610275],[-1.856945,34.616386],[-1.853889,34.620827],[-1.824722,34.645828],[-1.814722,34.650833],[-1.805833,34.657219],[-1.795833,34.670555],[-1.749167,34.741104],[-1.747222,34.747215],[-1.75,34.751663],[-1.754445,34.754997],[-1.765,34.760551],[-1.784167,34.766937],[-1.798889,34.769997],[-1.804167,34.772774],[-1.856389,34.801384],[-2.075,34.943604],[-2.180278,35.012215],[-2.196389,35.026665],[-2.203333,35.034439],[-2.206667,35.044441],[-2.209445,35.085831],[-2.165,35.096939],[-2.158889,35.098328],[-2.152223,35.097496],[-2.124722,35.090271],[-2.111111,35.086388],[-2.100278,35.081108],[-2.095834,35.077774],[-2.065556,35.071938],[-2.03,35.071938],[-1.979722,35.073326],[-1.940556,35.079163],[-1.896667,35.087494],[-1.780556,35.117218],[-1.753889,35.128326],[-1.744445,35.134163],[-1.732222,35.144997],[-1.698889,35.173607],[-1.563334,35.257217],[-1.548889,35.266106],[-1.524167,35.279442],[-1.474445,35.305832],[-1.468333,35.30722],[-1.446667,35.308052],[-1.439167,35.307777],[-1.416389,35.303604],[-1.401667,35.303886],[-1.389445,35.306389],[-1.371945,35.311943],[-1.366667,35.313889],[-1.360748,35.317787],[-1.352222,35.322495],[-1.297778,35.359993],[-1.278333,35.377777],[-1.270833,35.385826],[-1.259167,35.406662],[-1.249167,35.436386],[-1.24,35.467216],[-1.225278,35.5],[-1.222778,35.505272],[-1.196944,35.551109],[-1.168889,35.577499],[-1.126111,35.606667],[-1.03583,35.676941],[-1.009444,35.68055],[-1.003056,35.681938],[-0.902778,35.711388],[-0.791667,35.764999],[-0.697222,35.719719],[-0.65,35.712776],[-0.642222,35.712494],[-0.618056,35.71833],[-0.534444,35.766388],[-0.529444,35.76944],[-0.521111,35.776665],[-0.514444,35.785271],[-0.508333,35.794998],[-0.493889,35.82],[-0.480278,35.846107],[-0.476111,35.858055],[-0.474722,35.864716],[-0.38,35.902222],[-0.373889,35.90361],[-0.358611,35.903053],[-0.342778,35.900276],[-0.3375,35.897499],[-0.300833,35.871109],[-0.2975,35.867218],[-0.296667,35.861382],[-0.303333,35.852776],[-0.304722,35.847221],[-0.303333,35.842216],[-0.300556,35.837776],[-0.293611,35.829994],[-0.289167,35.82666],[-0.244444,35.810829],[-0.144167,35.788055],[-0.120833,35.783607],[-0.114294,35.783699],[-0.1125,35.782494],[-0.100833,35.785553],[-0.052222,35.806107],[0.011111,35.842773],[0.02,35.849159],[0.028333,35.856384],[0.036111,35.864441],[0.047222,35.876938],[0.084444,35.942497],[0.117222,36.005554],[0.118056,36.017776],[0.122778,36.037216],[0.125,36.043327],[0.128333,36.047775],[0.1325,36.051384],[0.204167,36.103333],[0.33,36.167496],[0.537778,36.26944],[0.615833,36.305832],[0.6775,36.328049],[0.72998,36.332603],[0.736944,36.332222],[0.757222,36.33416],[0.768333,36.338333],[0.839722,36.365829],[0.866944,36.376663],[0.911944,36.401665],[0.916111,36.405273],[0.919722,36.409439],[0.923889,36.421387],[0.9325,36.436943],[0.945,36.447495],[0.95,36.450272],[1.025,36.473885],[1.1825,36.512215],[1.406389,36.529716],[1.489722,36.523331],[1.503611,36.523888],[1.5675,36.531387],[1.613889,36.537216],[1.643333,36.545555],[1.655833,36.54805],[1.691667,36.548882],[1.722219,36.547218],[1.733611,36.551384],[1.751944,36.55555],[1.8425,36.567497],[1.898611,36.570274],[1.913333,36.570274],[1.950278,36.561386],[1.965555,36.560555],[1.979444,36.561104],[2.041111,36.566109],[2.0475,36.567215],[2.142222,36.584442],[2.159166,36.590271],[2.174166,36.59861],[2.179722,36.600555],[2.221111,36.611664],[2.309033,36.629585],[2.339167,36.635277],[2.355278,36.633606],[2.370833,36.630554],[2.383611,36.625832],[2.394444,36.619995],[2.397778,36.616104],[2.400278,36.611382],[2.398889,36.604721],[2.399167,36.599159],[2.4025,36.594994],[2.41,36.59333],[2.434444,36.590271],[2.474166,36.586388],[2.496111,36.584442],[2.503889,36.58416],[2.566111,36.588051],[2.578888,36.590271],[2.591666,36.592499],[2.603611,36.595551],[2.626111,36.603333],[2.779444,36.677216],[2.811666,36.69944],[2.820833,36.705826],[2.833333,36.716942],[2.839167,36.727219],[2.894444,36.792496],[2.903055,36.796104],[2.908889,36.79805],[2.934166,36.802498],[2.96361,36.802216]]]

1 个答案:

答案 0 :(得分:2)

要使其工作,必须将coordsToLatLngs()的第二个参数设置为1(因为它是一个数组数组,请参见doc):

const latLngs = L.GeoJSON.coordsToLatLngs(data, 1);

现在它正在工作:

https://codepen.io/anon/pen/VOmwoa