Google Maps tied to Collection wont pin

I’m trying to pin a location on Google Maps, tied to my CMS collection using Javascript Velo code:

$w.onReady(function () {
	$w('#dynamicDataset').onReady( () => {
        let currentitem = $w('#dynamicDataset').getCurrentItem();

		
    $w('#googleMaps1').location = {

        "latitude": currentitem.latitude,
        "longitude": currentitem.longitude,
        "description": currentitem.title,

    };
} );
	  } );

But the pin is stuck on Wix Office. I don’t want to use the html frame because I have to pin more than 100 locations.

You should be able to set it without code using the data connect icon on the map element.

Tried that, and set all fields but still stuck on Wix office pin on Preview/Live Mode.

I got this solved using the CMS data connection. The field should be set as an Address field, and I need to retype the address so that it reads the location on Google Map.

Oh, wrong field. That makes sense. I knew it could be done without code!

Good job figuring it out!

1 Like

I have an address field in my collection, but Google Maps only wants to show the wix office or other manually entered addresses. I have Google Maps connected to my collection, dataset and the address field, but it won’t display the hundreds of locations I have in my CMS collection. What am I missing?

I figured it out.

In the dataset settings, I had to set up a filter that makes sure the address field is not empty. (I had one location without an address and it killed the entire map)

2 Likes