Hello!
There is a way that i can add map in my dynamic page and connect it to the database?
Thank you
Hay nevo,
Sure you can, but you will need some coding.
The map APIs accept a geo location . Given you have the location in your database, lets assume in the field location, what you can is set the map location on the dataset onReady event.
$w('#DATASET').onReady(() => {
let location = $w('#DATASET').getCurrentItem().location;
let addressSummary = $w('#DATASET').getCurrentItem().address;
$w('#MAP').location = {
latitude: location.lat,
longitude: location.long,
description: addressSummary
}
});
Thank you for the fast reply!
Hey nevo - did you ever get this to work?
No
Shame - I realise the system is still new but if anyone else has managed to pull google coordinates from a database to display a relevant map, can you share the process please? Yoav gave a good, quick response, but many of us just aren’t that skilled enough to follow his instruction - I get errors I don’t know what to do with…
I agree with you. I am new at this too
Hi Gwix and Nevo,
Feel free to paste here your code.
We will have a look.
Roi
Thanks Roi (I’ve been away) - shall be catching-up on this project and seeing if you’re still around to help out.
Hey Roi,
i actually planned to use Yoavs code. I replaced his Information about the database and the html body with mine but WIX still gives me a lot of errors. The values i enter “arent valid selector names”. Any clue why the code above wont work?
Greetings,
Dawd
Try this :
$w.onReady(function () {
$w(“#dynamicDataset”).onReady(() => {
let currentItem = $w(“#dynamicDataset”).getCurrentItem();
$w(“#googleMaps1”).location = {
“latitude”: currentItem.latitude,
“longitude”: currentItem.longitude,
“description”: currentItem.description
};
});
});
Thank you for your input whoudoux. I also spotted that code a while ago in another discussion.
WIX keeps telling me that my location (in $w(" #googleMaps1 "). location = … is undefined. I mustve done something wrong because i dont hear anybody complaning about that. Haha
Plus, i think that my html code is not prepared for that function. It is centered on a specific point on the map and i dont prepare any marker function. But i honestly dont know what to write there exactly. Any hints?
Greetings, Dawd
Oh, i got it working now! Finally! My problem was that i inserted a map via html code. But i just had to use the map provided by WIX. Awesome!
OK, thanks for all the great info.
Now a follow up question…
I have developed a custom Event Detail page on which I would like to place a map.
But as far as I can tell I cannot add columns to the Wix Events collection to store long and lat
Any idease?
Wix Events is a Wix app and there is a set limit as to what you can do with it through code and not through the Wix Events app own settings itself.
https://support.wix.com/en/article/corvid-wix-events-events-collection-fields
https://support.wix.com/en/article/creating-a-custom-events-gallery
https://support.wix.com/en/article/creating-a-custom-event-details-page
https://support.wix.com/en/wix-events/setting-up-wix-events