1
I’m trying to assemble a map of google maps with some pins, where the strings will be passed through the URL.
However I need to pass an array like this to the API:
var locations = [
['First Place', -37.808204, 144.855579],
['Second Place', -37.675648, 145.026125],
['Third Place', -37.816935, 144.966877]
];
In my code I managed to get the parameters and mount an array, but it’s not like what I need and I’m not sure how to improve. This is the code I’ve assembled so far:
var query = location.search.slice(1);
var places = query.split('&');
var locations = [];
places.forEach(function (place) {
var chaveValor = place.split('=');
var local = chaveValor[0];
var cordenadas = chaveValor[1].split(",");
locations[local] = cordenadas;
});
console.log(locations);
assuming the url is:
https://localhost/GoogleMaps/index.html?First-Place=-37.808204,144.855579&Second-Place-Teste=-37.675648,145.026125
It’s returning the following:
[First-Place: ["-37.808204", "144.855579"], Second-Place-Teste: ["-37.675648", "145.026125"]]
Thank you very much for those who can help.
Thank you very much friend, solved my problem.
– user8811593
Blz... I added some more information at the end of the reply. Abs!
– Sam