0
votes

Trying to use: https://developers.google.com/apps-script/articles/maps_tutorial?hl=en I receive the map correctly. However, I would like for the map to remain on one tab. The bottom of the code reads:

SpreadsheetApp.getActiveSpreadsheet().show(ui);

And I think I should change it to

SpreadsheetApp.getActiveSpreadsheet().getSheetByName('restaurants').show(ui);

so that the map remains on one tab. But it gives me an error message. What can I do?

2

2 Answers

0
votes

You are getting an error message because there is no .show() method for the Sheet Class. The ui is attached to a Spreadsheet, not a Sheet. (Comparing to Excel, Spreadsheet == Workbook, Sheet == Worksheet aka tab.)

If you want to ensure that the sheet (tab) containing the map is visible, use Sheet.activate().

 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var mapSheet = ss.getSheetByName("Map");  // Assuming sheet is named Map
 mapSheet.activate();                      // Bring Map to front
 ss.show(ui);                              // Open UI
0
votes

You have to name the tab of the spreadsheet as 'restaurants', not the spreadsheet.