Skip to content

EspoCRM – Open Source CRM Application

google map id

Yuri Kuznetsov5b1919b76050
diff --git a/application/Espo/Hooks/Integration/GoogleMaps.php b/application/Espo/Hooks/Integration/GoogleMaps.php
index 31149a4f7a..4419794559 100644
--- a/application/Espo/Hooks/Integration/GoogleMaps.php
+++ b/application/Espo/Hooks/Integration/GoogleMaps.php
@@ -53,15 +53,16 @@ class GoogleMaps
return;
}
- if (!$entity->get('enabled') || !$entity->get('apiKey')) {
- $this->configWriter->set('googleMapsApiKey', null);
+ $apiKey = $entity->get('apiKey');
+ $mapId = $entity->get('mapId');
- $this->configWriter->save();
-
- return;
+ if (!$entity->isEnabled()) {
+ $apiKey = null;
+ $mapId = null;
}
- $this->configWriter->set('googleMapsApiKey', $entity->get('apiKey'));
+ $this->configWriter->set('googleMapsApiKey', $apiKey);
+ $this->configWriter->set('googleMapsMapId', $mapId);
$this->configWriter->save();
}
diff --git a/application/Espo/Resources/i18n/en_US/Integration.json b/application/Espo/Resources/i18n/en_US/Integration.json
index 5fd0379576..af071cd86b 100644
--- a/application/Espo/Resources/i18n/en_US/Integration.json
+++ b/application/Espo/Resources/i18n/en_US/Integration.json
@@ -7,7 +7,8 @@
"apiKey": "API Key",
"siteKey": "Site Key",
"secretKey": "Secret Key",
- "scoreThreshold": "Score Threshold"
+ "scoreThreshold": "Score Threshold",
+ "mapId": "Map ID"
},
"titles": {
"GoogleMaps": "Google Maps",
diff --git a/application/Espo/Resources/metadata/integrations/GoogleMaps.json b/application/Espo/Resources/metadata/integrations/GoogleMaps.json
index 9e33ec5f80..6b215acb96 100644
--- a/application/Espo/Resources/metadata/integrations/GoogleMaps.json
+++ b/application/Espo/Resources/metadata/integrations/GoogleMaps.json
@@ -4,6 +4,11 @@
"type": "varchar",
"maxLength": 255,
"required": true
+ },
+ "mapId": {
+ "type": "varchar",
+ "maxLength": 64,
+ "required": false
}
},
"allowUserAccounts": false,
diff --git a/client/src/handlers/map/google-maps-renderer.js b/client/src/handlers/map/google-maps-renderer.js
index 488c8bfd9d..5f907f3778 100644
--- a/client/src/handlers/map/google-maps-renderer.js
+++ b/client/src/handlers/map/google-maps-renderer.js
@@ -81,13 +81,15 @@ class GoogleMapsRenderer extends MapRenderer {
const geocoder = new google.maps.Geocoder();
let map;
+ const mapId = this.view.getConfig().get('googleMapsMapId') || 'DEMO_MAP_ID';
+
try {
// noinspection SpellCheckingInspection,JSUnresolvedReference
map = new google.maps.Map(this.view.$el.find('.map').get(0), {
zoom: 15,
center: {lat: 0, lng: 0},
scrollwheel: false,
- mapId: 'DEMO_MAP_ID', // @todo Use user defined. Fallback to 'DEMO_MAP_ID'.
+ mapId: mapId,
});
}
catch (e) {