Mapbox:当我尝试更改geojson对象的经度/纬度时,该列表不起作用 [英] Mapbox: The list does not work when I try to change the lat/long of the geojson objects

查看:347
本文介绍了Mapbox:当我尝试更改geojson对象的经度/纬度时,该列表不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了这段代码,并且效果很好,直到尝试更改标记的位置.例如,在geojson数组中,我更改了第一个变量的属性,当我在列表上单击它时,它仅显示标记(没有地图).任何人都可以看到问题所在吗?

I tried out this code and it works perfectly, until I try to change the position of the markers. For example, in the geojson array, I changed the first variable's properties and when i click it on the list, it only shows the marker (no map). Could anyone see what the issue might be??

以下是代码: 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."
    }

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

As you can see, the first item on the list brings you to an unrecognized location. But the other items work just fine.

推荐答案

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

It seems you have swapped your latitude and longitude:

"coordinates": [
    34.022591187904126, -118.28702688217165
]

那是无效的,纬度现在超过-90/90的边界,并且地图不知道该怎么做.如果您将它们交换,则效果很好:

That's invalid, the latitude now exceeds the boundaries of -90/90 and the map doesn't know what to do with that. If you swap them, it works perfectly:

"coordinates": [
    -118.28702688217165, 34.022591187904126
]

这篇关于Mapbox:当我尝试更改geojson对象的经度/纬度时,该列表不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆