Skip to content

Instantly share code, notes, and snippets.

@sudevschiz
Last active January 29, 2016 06:50
Show Gist options
  • Save sudevschiz/11026836 to your computer and use it in GitHub Desktop.
Save sudevschiz/11026836 to your computer and use it in GitHub Desktop.
findLatLong
function findLatLong() {
var sheet = SpreadsheetApp.getActiveSheet();
SpreadsheetApp.getUi().alert('Hello, world!');
var startRow = 2; // First row of data to process
var numRows = 2; // Number of rows to process
// Fetch the range of cells A2:B3
var dataRange = sheet.getRange(startRow, 2, numRows, 2)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var url = 'https://maps.googleapis.com/maps/api/geocode/json?'
+ 'address='
+ row[0]
+ '&sensor=false';
var response = UrlFetchApp.fetch(url);
Logger.log(response);
var json = response.getContentText();
var pjson = JSON.parse(json);
//ui.prompt('Getting to know you', 'May I know your name?');
var cell = sheet.getRange("B1");
Browser.msgBox(pjson.title);
}
}
@sudevschiz
Copy link
Author

This is a googleScript code to find the latitude and longitude of an address which is stored in a spreadsheet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment