4 <& /elements/header-popup.html, {
6 head => include('.head'),
7 etc => 'onload="initialize()"',
12 <div id="directions_panel"></div>
13 <div id="map_canvas"></div>
16 <& /elements/header-popup.html &>
17 <& /elements/google_maps_api_key.html &>
21 % my $lat = $cgi->param('lat');
22 % my $lon = $cgi->param('lon');
23 <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
25 <style type="text/css">
28 body { height: 100%; margin: 0px; padding: 0px }
43 #map_canvas { height: 500px; margin: 0; }
44 #directions_panel { float: none; width: auto; }
48 <script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3&key=<% $apikey %>">
51 <script type="text/javascript">
55 function show_route() {
56 var panel = document.getElementById('directions_panel');
57 var directionsService = new google.maps.DirectionsService;
58 var directionsDisplay = new google.maps.DirectionsRenderer;
59 directionsDisplay.setMap(map);
60 directionsDisplay.setPanel(panel);
62 var directionsRequest = {
63 origin: <%$origin |js_string%>,
64 destination: <% $lat %>+","+<% $lon %>,
65 travelMode: google.maps.TravelMode.DRIVING
68 directionsService.route(directionsRequest, function(result, status) {
69 if ( status == google.maps.DirectionsStatus.OK ) {
70 directionsDisplay.setDirections(result);
72 document.body.innerHTML = ('<P STYLE="color: red;">Directions lookup failed with the following error: '+status+'</P>');
77 // function name specified by google maps api, special hook for auth errors
78 function gm_authFailure () {
79 document.body.innerHTML =
80 <% include('/elements/google_maps_api_key.html', autherror => 1) |js_string%>;
83 function initialize() {
87 mapTypeId: google.maps.MapTypeId.ROADMAP
90 map = new google.maps.Map(
91 document.getElementById("map_canvas"),
94 map.setOptions( {rotateControl : true });
101 my ($lat, $lon, $name, $origin);
102 my $conf = new FS::Conf;
103 my $apikey = $conf->config('google_maps_api_key');
107 $name = $cgi->param('name');
109 $lat = $cgi->param('lat');
110 $lon = $cgi->param('lon');
111 $lat =~ /^-?\d+(\.\d+)?$/ or die "bad latitude: $lat";
112 $lon =~ /^-?\d+(\.\d+)?$/ or die "bad longitude: $lat";
114 $origin = $cgi->param('origin') or die "no origin specified";