-% if ( $apikey ) {
-
%# the actual page
<& /elements/header-popup.html, {
title => '',#$name,
<div id="directions_panel"></div>
<div id="map_canvas"></div>
-% } else {
-<& /elements/header-popup.html &>
-<& /elements/google_maps_api_key.html &>
-% }
-
<%def .head>
% my $lat = $cgi->param('lat');
% my $lon = $cgi->param('lon');
}
</style>
-<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">
if ( status == google.maps.DirectionsStatus.OK ) {
directionsDisplay.setDirections(result);
} else {
- document.body.innerHTML = ('<P STYLE="color: red;">Directions lookup failed with the following error: '+status+'</P>');
+ var errmsg = ('<P STYLE="color: red;">Directions lookup failed with the following error: '+status+'</P>');
+ if (status == 'REQUEST_DENIED') {
+ errmsg = errmsg + <% include('/elements/google_maps_api_key.html' ) |js_string%>;
+ }
+ document.body.innerHTML = errmsg;
}
});
}
// 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 => 1) |js_string%>;
+<% include('/elements/google_maps_api_key.html', autherror => $apikey ) |js_string%>;
}
function initialize() {