Google Map's Direction and Putting it on Repeater

Hi Wix

Im using google map on my dynamic page and repeater. The problems are:

  1. Direction always end to Wix office location. I set up the latitude and longitute on database and it show the correct location on the google map (dynamic page) but misleading when clicking the direction link.

  2. Anyone has successfully attached google map into repeater?

Thanks,
DA

Are you using any Wix Corvid example as you mention that it always points to the Wix Offices?
Post any used code and screenshots here so that it can be looked over and checked etc.

Also, have a look at GoogleMap and Repeater in the Wix API Reference here.
https://www.wix.com/corvid/reference/$w.GoogleMap.html
https://www.wix.com/corvid/reference/$w.Repeater.html

Hi @sailorcihan

im using this code and populated the latitude and longitude through database (dynamic page).

function googleMap() {
let itemData = $w(‘#dynamicDataset’).getCurrentItem();
$w(‘#googleMaps1’).location = {
“latitude”: itemData.latitude,
“longitude”: itemData.longitude,
“description”: itemData.title + ’ | ’ + itemData.cityAddress + ’ Branch, ’ + itemData.provinceState
};
}

The map shows the right location but when clicking the direction link it start from my current location to address set up in the google map setting.

It is misleading the visitors. I wanted the direction should start from my current location to the data send to google map’s latitude and longitude.

Any pointers?

And seems like google map cant be attached to repeater. Try it?

DA

1 Like
This works for me.

$w.onReady(function () {
$w("#dynamicDataset").onReady(() => {
let currentItem = $w("#dynamicDataset").getCurrentItem();
$w("#googleMaps1").location = {

//next data base field latitude
"latitude": currentItem.latitude,
//next data base field longitude
"longitude": currentItem.longitude,
//next data base field name of site, restaurant, etc
"description": currentItem.nombre_emp,
};
});
});

@abigailx1

And the direction’s link provide the right direction upon clicking it?

The code works and show the right place in the google map but direction’s link does not provide the correct end point based on latitude and longitude from dynamicdataset. It always end with the address set manually on the google map’s setting which cant be leave empty too.

Did you manage to attached google map to repeater’s container too?

Thanks,
DA

1 Like

You are right it is not possible, I put a standard local address as something by default for when they do not put the location data and delete the address link so I simply visualize a point on the map but I cannot offer a route.

We are 2 with the same problem, hopefully someone helps us.

Apologies to revive an old thread, but is there any further development to this? I have a dynamic page set up, linked to a database, then using a Google Map object to display the location of a specific location by calling the Lat + Lon from the database.

This part works fine, but as discussed above, if you use the “Directions” link on the Google Maps object, you always get directions to the Wix HQ.

I’ve tried using the following code, but to no avail.

import wixData from 'wix-data';
import wixLocation from 'wix-location';

$w.onReady(function () {
 let currentItem = $w('#teamDataset').getCurrentItem();

    $w('#googleMaps1').location = {
 "latitude": currentItem.latitude,
 "longitude": currentItem.longitude,
 "description": currentItem.dealer,
 "direction": currentItem.latitude + currentItem.longitude,
    }

});

export function directionsLink_click(event) {
 const lat = $w("#teamDataset").getCurrentItem().latitude;
 const lon = $w("#teamDataset").getCurrentItem().longitude;
 const coordinates = lat + "," + lon;
    wixLocation. to("https://www. google. com/maps/dir///@" + coordinates);
}
//ignore spaces in the URL above - purely for posting here

Does anyone have any further advice? Or is this something that’s not possible yet?

Thanks,
JackBDC