summaryrefslogtreecommitdiff
path: root/altosuilib/AltosSiteMap.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-05-28 00:42:24 -0700
committerKeith Packard <keithp@keithp.com>2014-05-28 00:42:24 -0700
commit3773e89c47d356c4df58edc5725c33bca89b9605 (patch)
treecd5dfe6f87cad5b5b58d6949e5776859d7aff7ab /altosuilib/AltosSiteMap.java
parente6cfa25702b3dc1d492c5f1a4d0b4ba4831d30bd (diff)
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 <keithp@keithp.com>
Diffstat (limited to 'altosuilib/AltosSiteMap.java')
-rw-r--r--altosuilib/AltosSiteMap.java15
1 files changed, 10 insertions, 5 deletions
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;