Я использую mapbox на моем View и мне нужно добавить несколько маркеров из JSON
Вот мой JSON
[
{
"name":"Thistle London Heathrow Termin",
"address1":"Bath Road",
"rating":3.0,
"lng":-0.4836,
"lat":51.4805
},
{
"name":"Ibis London Heathrow Airport",
"address1":"112 Bath Road Hayes",
"rating":3.0,
"lng":-0.430683,
"lat":51.48079
},
{
"name":"Britannia Inn",
"address1":"54 Mansfield Road",
"rating":2.0,
"lng":0.066,
"lat":51.563
},
{
"name":"Cranbrook Hotel",
"address1":"22 24 Coventry Road",
"rating":2.0,
"lng":0.069,
"lat":51.563
},
{
"name":"Park Hotel",
"address1":"327 Cranbrook Road",
"rating":2.0,
"lng":0.065,
"lat":51.568
},
{
"name":"Rest Up London",
"address1":"Driscoll House",
"rating":2.0,
"lng":-0.096403,
"lat":51.494554
},
{
"name":"Ascot Hyde Park",
"address1":"11 Craven Road",
"rating":3.0,
"lng":-0.176815,
"lat":51.514745
},
{
"name":"Fairways Bayswater",
"address1":"186 Sussex Gardens",
"rating":2.0,
"lng":-0.1748,
"lat":51.5144
},
{
"name":"Four Stars",
"address1":"26 28 Sussex Gardens",
"rating":3.0,
"lng":-0.1685,
"lat":51.5179
},
{
"name":"King Solomon",
"address1":"155 159 Golders Green Road",
"rating":3.0,
"lng":-0.21045388,
"lat":51.58082156
},
{
"name":"Somerset.",
"address1":"6 Dorset Square",
"rating":2.0,
"lng":-0.1607,
"lat":51.5229
},
{
"name":"Trinity House",
"address1":"26 Blackhorse Raod",
"rating":2.0,
"lng":-0.0356,
"lat":51.5832
},
{
"name":"Viking",
"address1":"162 Romford Road",
"rating":2.0,
"lng":0.01299262,
"lat":51.54324077
},
{
"name":"Wedgewood",
"address1":"49 51 Leinster Square",
"rating":2.0,
"lng":-0.1928,
"lat":51.51365
},
{
"name":"Kensington Suite",
"address1":"128 130 Holland Road",
"rating":3.0,
"lng":-0.2121,
"lat":51.5015
}
]
И вот как я запускаю скрипт для добавления карты в View
let centerLatlng = new mapboxgl.LngLat(gon.destination_city.lng,gon.destination_city.lat);
mapboxgl.accessToken = token;
let map = new mapboxgl.Map({
container: 'map-canvas',
style: 'mapbox://styles/mapbox/streets-v9',
center:centerLatlng,
zoom: 9
});
map.addControl(new mapboxgl.NavigationControl());
});
Но мне интересно, как мне нужно добавить маркеры на карту (для каждого элемента в json мне нужно получить lat и lon) на карту.Потому что в соответствии с документами мне нужно, чтобы json был следующим: [-77.032, 38.913]}, свойства: {title: 'Mapbox', описание: 'Washington, DC'}}, {type: 'Feature', geometry: {type: 'Point', координаты: [-122.414,37.776]}, свойства: {title: 'Mapbox', описание: 'San Francisco, California'}}]};
Могу ли я делать маркеры с помощью моего json