Last active
January 29, 2016 06:50
-
-
Save sudevschiz/11026836 to your computer and use it in GitHub Desktop.
findLatLong
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a googleScript code to find the latitude and longitude of an address which is stored in a spreadsheet.