From 3773e89c47d356c4df58edc5725c33bca89b9605 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 28 May 2014 00:42:24 -0700 Subject: altosuilib: Add google maps API key, configured with -with-google-key This places the actual key outside of the repository, allowing the user to configure the name of the file containing the key. By default, this pulls the key from $HOME/altusmetrumllc/google-maps-api-key. With the key present, there are no longer any rate limits to loading map data. Signed-off-by: Keith Packard --- altosuilib/AltosSiteMap.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'altosuilib/AltosSiteMap.java') diff --git a/altosuilib/AltosSiteMap.java b/altosuilib/AltosSiteMap.java index ee9b8c05..d9ea564c 100644 --- a/altosuilib/AltosSiteMap.java +++ b/altosuilib/AltosSiteMap.java @@ -263,8 +263,6 @@ public class AltosSiteMap extends JComponent implements AltosFlightDisplay, Mous AltosSiteMap asm = new AltosSiteMap(true); asm.centre = asm.getBaseLocation(lat, lng); - //Point2D.Double p = new Point2D.Double(); - //Point2D.Double p2; int dx = -w/2, dy = -h/2; for (int y = dy; y < h+dy; y++) { for (int x = dx; x < w+dx; x++) { @@ -334,8 +332,10 @@ public class AltosSiteMap extends JComponent implements AltosFlightDisplay, Mous private void initMaps(double lat, double lng) { setBaseLocation(lat, lng); - for (AltosSiteMapTile tile : mapTiles.values()) + for (AltosSiteMapTile tile : mapTiles.values()) { tile.clearMap(); + tile.set_status(AltosSiteMapCache.loading); + } Thread thread = new Thread() { public void run() { for (Point k : mapTiles.keySet()) @@ -369,8 +369,13 @@ public class AltosSiteMap extends JComponent implements AltosFlightDisplay, Mous format_string = "jpg"; else format_string = "png32"; - return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=%s&format=%s", - lat, lng, zoom, px_size, px_size, maptype_names[maptype], format_string); + + if (AltosUIVersion.has_google_maps_api_key()) + return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=%s&format=%s&key=%s", + lat, lng, zoom, px_size, px_size, maptype_names[maptype], format_string, AltosUIVersion.google_maps_api_key); + else + return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=%s&format=%s", + lat, lng, zoom, px_size, px_size, maptype_names[maptype], format_string); } boolean initialised = false; -- cgit v1.2.3