Map to mark location on map based on Long and lat stored in Dataset

Hi i’m really hoping someone can help me out here.

  • I have stored the location of gyms in a dataset (featuredBoxsDataset).

  • They are stored in two columns named, Longitude & Latitude, and type: Number

  • The dataset is linked to the page

  • This is a dynamic page
    I would like to make it so that when the page for each gym loads the location for the gym is marked on the map.

I have put my current attempt below but nothing is changing on the map.
Any ideas what I am going wrong.

The highlighted ‘item’ isn’t liked it says ‘the keyword ‘let’ is reserved’

Thanks in advance.

You can’t declare variables inside the location object. The code should look something like this:

let item = $w("FeaturedBoxDataset").getCurrentItem();
let lon = item.longitude;
let lat = item.latitude;
$w("#BoxLocationmap").location = {
                                "latitude": lat,
                                "longitude": lon,
                                "description" : "Box Location"
                              };

I would also suggest visiting the following sites for information on programming in Javascript:

Thanks,
I’ve had a go at that but it’s not making any difference. See the code below. Have I done this right?

Thanks

Your problem is that you try to do a var declaration and asignation inside an array. That is a novel aproach to say the least. Try this:

let item = $w('#FeaturedBoxDataset').getCurrentItem();
let longitude = item.longitude;
let latitude = item.latitude;
$w('#BoxLocationmap').location = {
 "longitude": longitude,
 "latitude": latitude
        };
1 Like

“A novel approach” XD
Not all bravery pays off.

1 Like

Hi, I’m looking to add a feature to my website where the visitors can see the store’s nearby to them. How should I go about this?
I want them to see only the one’s closest to them. And if they wish to see other stores, they can zoom out.
Thank you!

i feel your situation. Some of these map api’s conveniently forget about “streets with no names.” :rage: