How do I after adding Google map app be able to extract and pull from my collection database to pull “address”, “latitude” and “longitude” field to show on the google map, per each dynamic page (which is per row)?
Please help me as I’m new to wix and please tell me where to edit the javascript code if coding is needed. Thanks!
Hey,
If you don’t have the longitude & latitude in your DB, my answer here would help you a lot.
But if you have them in the database. check this:
you would just use this to add your location.
$w("#myGoogleMap").location = {
"latitude": 37.77065,
"longitude": -122.387301,
"description":"Wix Office"
};
1 Like
Hey thanks a lot, I actually came up with a code and that works in “Preview” mode but I can’t seem to get it to show in published site…I’m not quite sure why?
import wixData from ‘wix-data’;
import {session} from ‘wix-storage’;
$w.onReady(function () {
$w(“#dynamicDataset”).onReady(() => {
let item = $w("#dynamicDataset").getCurrentItem();
console.log(item.latitude);
console.log(item.longitude);
$w("#googleMaps1").location = {
"longitude" : item.longitude,
"latitude" : item.latitude,
"description" : item.title
}
});
});
@wilsonwjching make sure that you synced the data to the live database. click on Sync.
@ahmdjsalhi great thanks bro!
@Ahmd Salhi can you help me? I have an “Area” field and for all the locations(lat+long) associated with a certain area, I want to display all the location points on a map. Any suggestions on how to do this?
@wilsonwjching you can’t put more than one location on google map that used in wix. though you could use html code or other map.
also you could check this thread:
@ahmdjsalhi what is by HTML code? What’s the other map? Please help. Thanks!