Use the value of a Collection field in a Map

I want to use the value of a text field, which will be an address, for the tab in a Google map on a Collection Page. I already have the ID Key and the map is loaded onto the page. So each collection page will generate a different map. How do I do that?

If you use collection page on the read-only site, look at the page for George Edwards. His is the only one with a meaningful (though erroneous) address.

Thanks,
Marty

https://preview.webflow.com/preview/pledge-list?utm_source=pledge-list&preview=889c625dd810a87a339a28b942d4f732

Hi @mwulfe

You’ll need to add a HTML embed to your template page with the following code:

https://cl.ly/81d7fa

<iframe
width="100%"
height="100%"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?key=YOUR API KEY HERE
&q=DYNAMIC FIELD HERE" allowfullscreen>
</iframe>

In your collection list you’ll need a plain text field and the address needs to be added with + sign instead of spaces like so: 440+Avenue+du+Mont-Royal+E+Montréal+QC+H2J+1W1

Hope that helps! :slight_smile:

donaldsv, yes that helps for a start, although I was not sure what to do with the “DYNAMIC FIELD HERE” text so I left it unchanged. Then, using Webflow, how do I modify the value of a text field by substituting “+” characters for spaces? I am not a Javascript programmer. And once I do that, how do I submit that text to the map?

I do have a plain text field in my collection that is the address. Where would that go in the script? I was getting a rejection from Google, it was not accepting the key from that app even tho it accepted it from the Webfrow map control.

See the red arrow, you have to click on Add Field in the top right corner, then you select your address field from your collection.

The address needs to be entered with + signs in the plain text field instead of spaces since that’s how google URLs work.

https://cl.ly/81d7fa

This map component needs to be replaced with a HTML Embed element.

CloudApp

I inserted the address field name as shown, but I am still getting a rejection from Google:

You need to check your API settings in the google console.

All considered I think it would be easier to just include a button that is a link to the Google Maps page and let that open in a separate window. so Google Maps format should work, right?

Yeah! that’s another way to do it :slight_smile: