I'm currently working on a fire location tracking website and I'm facing an issue with leaflet.js. As a newcomer to Leaflet, any assistance would be greatly appreciated!
I have a script that successfully retrieves the id of a specific row from a connected SQL table:
var coordinates = [43.855202, 18.417892];//basic location data
var kordinate1 = [43.855202, 18.417892];//same as above
var kordinate;
//code for retrieving specific id below
const Listen = (doc) => {
return {
on: (type, selector, callback) => {
doc.addEventListener(type, (event)=>{
if(!event.target.matches(selector)) return;
callback.call(event.target, event);
}, false);
}
}
};
Listen(document).on('click', '.btn', function (e) {
idoffire = e.target.id - 100;//working properly
coordinates = document.getElementById(idoffire).innerHTML;//retrieving data from table with specific id, tried different methods like .innerText, .value but no success.
kordinate1 = coordinates.replace(/\s/g, ',');//table data only separated by spaces, need commas
kordinate = "[" + kordinate1 + "]"; //formatting for map.flyTo function, problem arises here.
console.log(kordinate);//kordinate output in console as shown in image below
map.flyTo(kordinate, 18);//PROBLEM HERE!
});
(ignore the e.target.id - 100, just a method for getting the specific id ;) )
https://i.stack.imgur.com/Z6oSm.png
Thank you in advance for your assistance!
Note: I'm not attempting to retrieve coordinates from user input since they are already stored in the database, making this question different from this one.
Once again, thank you for your help.