Fix for map link and display
authorSudha Bisht <sudha.bisht@webaccessglobal.com>
Thu, 28 May 2015 11:42:14 +0000 (17:12 +0530)
committerSudha Bisht <sudha.bisht@webaccessglobal.com>
Thu, 28 May 2015 11:42:14 +0000 (17:12 +0530)
CRM/Contact/Selector.php
CRM/Contact/Selector/Custom.php
templates/CRM/Contact/Form/Task/Map/Google.tpl

index d03e948fca57236ef2fab080130f8c7a60524aa5..d8920ae59f7ca9cb28dcf7b7b0448775912b4d99 100644 (file)
@@ -261,7 +261,8 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
       );
 
       $config = CRM_Core_Config::singleton();
-      if ($config->mapAPIKey && $config->mapProvider) {
+      //CRM-16552: mapAPIKey is not mandatory as google no longer requires an API Key
+      if ($config->mapProvider && ($config->mapAPIKey || $config->mapProvider == 'Google')) {
         self::$_links[CRM_Core_Action::MAP] = array(
           'name' => ts('Map'),
           'url' => 'civicrm/contact/map',
index ad66bf73cd62c2fc0029fe831df48e4ded676f79..ba671244a9de298f46d917e26dfea085c46d272a 100644 (file)
@@ -183,7 +183,8 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
       );
 
       $config = CRM_Core_Config::singleton();
-      if ($config->mapAPIKey && $config->mapProvider) {
+      //CRM-16552: mapAPIKey is not mandatory as google no longer requires an API Key
+      if ($config->mapProvider && ($config->mapAPIKey || $config->mapProvider == 'Google')) {
         self::$_links[CRM_Core_Action::MAP] = array(
           'name' => ts('Map'),
           'url' => 'civicrm/contact/map',
index c7b5389c19dec48cc84836fc7a0cc8862d929966..0605982b99c33bc9a73846eb8c71b4f077b8343b 100644 (file)
@@ -32,7 +32,7 @@
 {/if}
 {assign var=defaultZoom value=16}
 {literal}
-<script src="//maps.googleapis.com/maps/api/js?{/literal}{if $mapKey}key={$mapKey}{/if}{literal}&sensor=false" type="text/javascript"></script>
+<script src="//maps.googleapis.com/maps/api/js?{/literal}{if $mapKey}key={$mapKey}{/if}{literal}&sensor=false&callback=initMap" type="text/javascript"></script>
 <script type="text/javascript">
     function initMap() {
         var latlng = new google.maps.LatLng({/literal}{$center.lat},{$center.lng}{literal});
   id  = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=780,height=640,left = 202,top = 100');");
     }
-
-    if (window.addEventListener) {
-        window.addEventListener("load", initMap, false);
-    } else if (window.attachEvent) {
-        document.attachEvent("onreadystatechange", initMap);
-    }
 </script>
 {/literal}
 <div id="google_map" style="width: {$width}; height: {$height}"></div>