Skip to content

Instantly share code, notes, and snippets.

@atomize
Created February 5, 2013 05:30
Show Gist options
  • Save atomize/4712432 to your computer and use it in GitHub Desktop.
Save atomize/4712432 to your computer and use it in GitHub Desktop.
Google Apps Script Maps Service in Spreadsheets - Get Lon/Lat + Generate Map UI (original: http://www.vicfryzel.com/2010/11/11/doing-some-useful-things-with-maps-in-google-apps-script)
function getLatitudeLongitude($address) {
var geocode = Maps.newGeocoder()
.geocode($address);
// See http://goo.gl/5mr1N for reference
return geocode.results[0].geometry.location.lng + ', '+ geocode.results[0].geometry.location.lat;
}
function generateMap() {
var address = "111 8 Ave., New York, NY 10011";
var mapUrl = Maps.newStaticMap()
.setMarkerStyle(Maps.StaticMap.MarkerSize.MID,
Maps.StaticMap.Color.RED,
"A")
.addMarker(address)
.setMarkerStyle(Maps.StaticMap.MarkerSize.MID,
Maps.StaticMap.Color.RED,
"B")
.addMarker("17 st and 8 ave, new york, ny")
.setCenter(address)
.setSize(500, 500)
.getMapUrl();
var ui = UiApp.createApplication();
ui.setTitle("Map");
var panel = ui.createFlowPanel()
.setSize("500px", "500px");
panel.add(ui.createImage(mapUrl));
ui.add(panel);
ui.setHeight(500);
ui.setWidth(500);
SpreadsheetApp.getActiveSpreadsheet().show(ui);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment