Index: /main/trunk/greenstone3/web/interfaces/default/transform/layouts/header.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/transform/layouts/header.xsl	(revision 37022)
+++ /main/trunk/greenstone3/web/interfaces/default/transform/layouts/header.xsl	(revision 37023)
@@ -45,4 +45,14 @@
     <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'siteAdmin']"/>
   </xsl:variable>
+
+  <xsl:template name="opt-google-maps-api">
+    <xsl:if test="/page/pageResponse/format/gsf:option[@name='mapEnabled']/@value = 'true'] or /page/pageResponse/format/gsf:option[@name='allowMapGPSEditing']/@value = 'true']">
+      
+      <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCofVTps3xHfMvIcTMHqYMMxe3xXfkAxnI&amp;libraries=drawing" type="text/javascript"><xsl:text> </xsl:text></script>
+      <script src="interfaces/{$interface_name}/js/map-scripts-shapes-util.js" type="text/javascript"><xsl:text> </xsl:text></script>
+      
+    </xsl:if>
+  </xsl:template>
+  
   <!-- Creates a header for the html page -->
   <xsl:template name="create-html-header">
@@ -125,5 +135,7 @@
     <script type="text/javascript" src="interfaces/{$interface_name}/js/jquery.blockUI.js"><xsl:text> </xsl:text></script>
     <script type="text/javascript" src="interfaces/{$interface_name}/js/ace/ace.js"><xsl:text> </xsl:text></script>
-	
+
+    <xsl:call-template name="opt-google-maps-api"/>
+
 	<!-- Cookie Consent Manager -->
 	<xsl:choose>
@@ -827,9 +839,8 @@
     </xsl:if>
   </xsl:template>
+
   
   <xsl:template name="map-scripts">
     <meta content="initial-scale=1.0, user-scalable=no" name="viewport"/>
-    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCofVTps3xHfMvIcTMHqYMMxe3xXfkAxnI&amp;libraries=drawing" type="text/javascript"><xsl:text> </xsl:text></script>
-	<script src="interfaces/{$interface_name}/js/map-scripts-shapes-util.js" type="text/javascript"><xsl:text> </xsl:text></script>
     <script src="interfaces/{$interface_name}/js/map-scripts.js" type="text/javascript"><xsl:text> </xsl:text></script>
     <gsf:script type="text/javascript">$(window).on("load", initializeMapScripts);</gsf:script>
Index: /main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl	(revision 37022)
+++ /main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl	(revision 37023)
@@ -356,13 +356,16 @@
 			<script type="text/javascript" src="interfaces/{$interface_name}/js/documentedit_scripts.js"><xsl:text> </xsl:text></script>
 			<script type="text/javascript" src="interfaces/{$interface_name}/js/documentedit_scripts_util.js"><xsl:text> </xsl:text></script>
-			<script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-shapes-util.js"><xsl:text> </xsl:text></script>
-			<script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-editor-history.js"><xsl:text> </xsl:text></script>
-			<script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-editor-themes.js"><xsl:text> </xsl:text></script>
-			<!-- LEAVE THIS NEXT LINE IN, IF USING CUSTOM OVERLAYS TO SHOW LABELS ON THE MAP -->
-			<!--<script type="text/javascript" src="interfaces/{$interface_name}/js/label-overlay-class.js"><xsl:text> </xsl:text></script>-->
-			<script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-editor.js"><xsl:text> </xsl:text></script>		
+
+			<xsl:if test="/page/pageResponse/format/gsf:option[@name='allowMapGPSEditing']/@value = 'true']">
+			  <script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-editor-history.js"><xsl:text> </xsl:text></script>
+			  <script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-editor-themes.js"><xsl:text> </xsl:text></script>
+			  <!-- LEAVE THIS NEXT LINE IN, IF USING CUSTOM OVERLAYS TO SHOW LABELS ON THE MAP -->
+			  <!--<script type="text/javascript" src="interfaces/{$interface_name}/js/label-overlay-class.js"><xsl:text> </xsl:text></script>-->
+			  <script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-editor.js"><xsl:text> </xsl:text></script>
+			  <link rel="stylesheet" href="interfaces/{$interface_name}/style/map-editors.css" type="text/css"/>						
+			</xsl:if>
+			
 			<script type="text/javascript" src="interfaces/{$interface_name}/js/hierarchy.js"><xsl:text> </xsl:text></script>
 			
-			<link rel="stylesheet" href="interfaces/{$interface_name}/style/map-editors.css" type="text/css"/>
 			
 			<script type="text/javascript">
