Po zamontowaniu mapki na moją stronke
state={
items:[{
"X": 13.6155611,
"Y": 51.0331258
},
],
}
componentDidMount() {
const map = new mapboxgl.Map({
container: this.mapContainer,
center: [this.state.lng, this.state.lat],
zoom: this.state.zoom,
});
for (var i = 0; i < this.state.items.length; i++) {
var obj = this.state.items[i];
let myLatlng = new mapboxgl.LngLat(obj.X, obj.Y);
new mapboxgl.Marker()
.setLngLat(myLatlng)
.addTo(map);
}
}
render() {
return (
<div ref={el => this.mapContainer = el} />
)}
Chciałbym wyswietlac markery po wpisaniu x i y, i czytac te dane z tablicy. Mam 2 inputy jeden dla X drugi dla Y po kliknieciu przycisku "add"
dodaje mi do tablicy te dane i mam 2 obiekty itp.. ale na mapie wyswietla mi się tylko jeden marker ten na sztywno wpisany w state.items mimo, z w tablicy mam wiecej wspolrzednych. Proszę o pomoc