Issue
suppose we have the following json data
var example = [{
latitude: 11.1111,
longitude: 111.111,
name: "for example1",
altitude: 88
},
{
latitude: 22.2222,
longitude: 222.222,
name: "for example2",
altitude: 89
},
{
latitude: 33.3333,
longitude: 333.333,
name: "for example3",
altitude: 90
}
]
I want to get the lists(or object) that has only latitude and longitude data, because Map API in my
react-native application require them. and by some performance issues, I can't use loop.
I know that writing a separate query(MySQL) can solve this problem, but I don't think this is good solution. (If not, I will very grateful if you can tell me)
thank you for reading this, how can I solve this?
Solution
I think you need this. it returns a new array with only lat/long items in objects
const newArray = example.map(el => {
return {
latitude: el.latitude,
longitude: el.longitude
}
})
Answered By - Konstantine Berulava
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.