地图框:当我尝试更改 geojson 对象的纬度/经度时,该列表不起作用



我尝试了这段代码,它运行良好,直到我尝试更改标记的位置。例如,在 geojson 数组中,我更改了第一个变量的属性,当我在列表中单击它时,它只显示标记(没有地图)。谁能看到问题可能是什么??

这是代码:http://plnkr.co/edit/ohumVwCE0CqcZOIkzPTa?p=preview

var geojson = [{
  "type": "FeatureCollection",
  "features": [{
    "type": "Feature",
    "geometry": {
      "type": "Point",
      "coordinates": [
        34.022591187904126, -118.28702688217165
      ]
    },
    "properties": {
      "phoneFormatted": "(213) 748-5116",
      "phone": "2022347336",
      "address": "1665 W Jefferson Blvd",
      "city": "Los Angeles",
      "country": "United States",
      "crossStreet": "at Jefferson",
      "postalCode": "90007",
      "state": "CA"
    }
  }, {
    "type": "Feature",
    "geometry": {
      "type": "Point",
      "coordinates": [-77.049766,
        38.900772
      ]
    },
    "properties": {
      "phoneFormatted": "(202) 507-8357",
      "phone": "2025078357",
      "address": "2221 I St NW",
      "city": "Washington DC",
      "country": "United States",
      "crossStreet": "at 22nd St NW",
      "postalCode": "20037",
      "state": "D.C."
    }

如您所见,列表中的第一项会将您带到无法识别的位置。但是其他项目工作得很好。

您似乎已经交换了纬度和经度:

"coordinates": [
    34.022591187904126, -118.28702688217165
]

这是无效的,纬度现在超过了-90/90的边界,地图不知道该怎么办。如果您交换它们,它可以完美运行:

"coordinates": [
    -118.28702688217165, 34.022591187904126
]

最新更新