RT# 81150 Google now requires api key for drawing api
authorMitch Jackson <mitch@freeside.biz>
Wed, 22 Aug 2018 18:14:30 +0000 (14:14 -0400)
committerMitch Jackson <mitch@freeside.biz>
Wed, 22 Aug 2018 19:04:52 +0000 (15:04 -0400)
FS/FS/deploy_zone.pm
httemplate/elements/polygon.html
httemplate/search/elements/gmap.html

index 6ad355f..7c3a76c 100644 (file)
@@ -6,7 +6,7 @@ use FS::Record qw( qsearch qsearchs dbh );
 use Storable qw(thaw);
 use MIME::Base64;
 
-use JSON qw(encode_json decode_json) ;
+use Cpanel::JSON::XS qw(encode_json decode_json);
 use LWP::UserAgent;
 use HTTP::Request::Common;
 
index 813aa41..b5aa937 100644 (file)
@@ -5,13 +5,16 @@ my $id = $opt{'id'} || $opt{'field'};
 my $div_id = "div_$id";
 
 my $vertices_json = $opt{'curr_value'} || '[]';
+
+my $apikey = FS::Conf->new->config('google_maps_api_key');
+
 </%init>
 <& hidden.html, %opt &>
 <div id="<% $div_id %>" style="height: 600px; width: 600px"></div>
 <div id="<% $div_id %>_hint" style="width: 100%; border: 2px solid black; text-align: center; box-sizing: border-box; padding: 4px">&nbsp;</div>
 
 <script src="<% $fsurl %>elements/jquery.js"></script>
-<script src="https://maps.googleapis.com/maps/api/js?libraries=drawing&v=3.22"></script>
+<script src="https://maps.googleapis.com/maps/api/js?libraries=drawing&v=3.22<% $apikey ? "&key=$apikey" : '' %>"></script>
 <script>
 var map;
 var drawingManager;
index 47db150..1caf767 100644 (file)
@@ -37,6 +37,9 @@ Generic Google Maps front end.
 
 </%doc>
 <%init>
+
+my $apikey = FS::Conf->new->config('google_maps_api_key');
+
 foreach (@features) {
   $_->{type} = 'Feature';
   # any other per-feature massaging can go here
@@ -57,7 +60,7 @@ body { height: 100%; margin: 0px; padding: 0px }
 #map_canvas { height: 100%; }
 </style>
 
-<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3">
+<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3<% $apikey ? "&key=$apikey" : '' %>">
 </script>
 
 <script type="text/javascript">