i s really good. I have copied and pasted the entire example and even created an api key. I have added this api key in place of “”
const key = “GOOGLE_MAP_API_KEY”;
I am wondering a) if this is the right place to put it and
if the api is correct in the first place, it is the only api key that i have in google cloud platform
It would be great to know how others create and link their api keys to this example
Note the check if (address.location) .
We do this because when address.location is present it means the visitor has entered text into the Address Input (rather than cleared the text), and selected one of the suggestions (rather than clicking outside the Address Input and leaving the entered text as is).
export function addressInput1_change(event) {
let address = $w('#addressInput1').value;
if (address && address.location) {
viewAddressOnMap(address);
}
}
function viewAddressOnMap(address) {
if (address && address.location) {
$w("#googleMaps1").location = {
"latitude": address.location.latitude,
"longitude": address.location.longitude,
"description": address.formatted
};
}
}
@eyalc Thanks so much, now what do i really need to do? I’m a little lost. I have added the address input to the page and a button although haven’t connected it yet to anything (should this be connected to a collection?)
Should the address input work just by typing? I have added the API key in settings
I have added the code snippets you provided and changed the properties to reflect the export function for address input 1
@eyalc Hi i got there in the end. So i was thinking can i add something like the following code to a dynamic page now that my collection has the address entered. Obviously this code doesn’t work at the moment but i’m sure its along the right lines.
the idea is simply to take address from collection which was populated by address input and display on a dynamic page map
$w.onReady( function () {
$w(“#dynamicDataset”).onReady( () => { let currentItem = $w(“#dynamicDataset”).getCurrentItem(); if (address && address.location) {
$w(“#googleMaps1”).location = {
“latitude”: currentItem.latitude,
“longitude”: currentItem.longitude,
“description”: currentItem.title,
};
}
} );
Hey @adcatch02 , very sorry that I missed your original message.
It would help me a great deal to take a look at your website and its code. Are you OK with me doing this?
If so, please pass me the URL of the published site (if published) or the metasite ID.
You can find the metasite ID in a URL param when you open the site with the Editor. It looks something like this: https://editor.wix.com/html/editor/web/renderer/edit/< ID>?metaSiteId= &editorSession…
@eyalc Hi Eyal, sure please find my editor url here. I’m not sure if you realise that i have the places API working and now just trying to find code to show the saved addresses on a map on a dynamic page. I am guessing that if it can work directly between address input and map it should be able to pick up the right info from the field key