问题
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??
Here is the code: 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.
回答1:
It seems you have swapped your latitude and longitude:
"coordinates": [
34.022591187904126, -118.28702688217165
]
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
]
来源:https://stackoverflow.com/questions/27025370/mapbox-the-list-does-not-work-when-i-try-to-change-the-lat-long-of-the-geojson