73107: Map regression: now always requiring API key
[freeside.git] / httemplate / view / directions.html
index a07df40..8377d12 100644 (file)
@@ -38,9 +38,7 @@ body { height: 100%; margin: 0px; padding: 0px }
 }
 </style>
 
-% my $conf = new FS::Conf;
-% my $apikey = $conf->config('google_maps_api_key');
-<script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3&key=<% $apikey %>">
+<script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3<% $apikey ? '&key='.$apikey : '' %>">
 </script>
 
 <script type="text/javascript">
@@ -69,6 +67,12 @@ function show_route() {
   });
 }
 
+// function name specified by google maps api, special hook for auth errors
+function gm_authFailure () {
+  document.body.innerHTML = 
+<% include('/elements/google_maps_api_key.html', autherror => $apikey ) |js_string%>;
+}
+
 function initialize() {
   var myOptions = {
     zoom: 14,
@@ -88,6 +92,8 @@ function initialize() {
 </%def>
 <%shared>
 my ($lat, $lon, $name, $origin);
+my $conf = new FS::Conf;
+my $apikey = $conf->config('google_maps_api_key');
 </%shared>
 <%init>