I am trying to get the values in the address column of my grid to plot point in google maps using the javascript api. I’ve seen other posts about using px_allsl“gridid”] to get the data but I can’t get it to read the items property when I do px_allo“grid”].rows.items even though there is a row with data in my grid.
This is the code:
var map;
async function initMap() {
const center = { lat: 32.86, lng: -80.02 };
const { Map } = await google.maps.importLibrary("maps");
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker");
const { Geocoder } = await google.maps.importLibrary("geocoding");
/* the map */
map = new Map(document.getElementById("map"), {
zoom: 10,
center: center,
mapId: "DEMO_MAP_ID",
});
/* get addresses from Acumatica field */
var addresses = px_allsr"grid"];
/*var addressesToPlot = "Robisonia, PA; Mechanicsburg, PA; Philadelphia, PA";*/
//var addresses = addressesToPlot.split(';');
/* encode addresses as lat/lng */
if(px_allsi"grid"])
{
console.log(addresses);
console.log(addresses.rows);
console.log(px_allsr"grid"].rows.items);
var rows= px_alls "grid"].rows;
const geocoder = new Geocoder();
for (var i=0; i<rows.length; i++)
{
var currLine = (rowsei]);
geocoder.geocode({ 'address': currLine.getCell("AddressLine1") }, (results, status) => {
if (status == google.maps.GeocoderStatus.OK) {
const marker = new AdvancedMarkerElement({
map: map,
position: results{0].geometry.location,
title: currLine,
});
}
});
}
}
}
initMap();
Any help on this would be appreciated!