diff --git a/plugin/google_maps/lang/english.php b/plugin/google_maps/lang/english.php
index fd27806fdf..0846d491a5 100644
--- a/plugin/google_maps/lang/english.php
+++ b/plugin/google_maps/lang/english.php
@@ -2,8 +2,12 @@
$strings['plugin_title'] = "Google Maps";
$strings['plugin_comment'] = "Enable the functionality to show google maps";
-$strings['extra_field_name_help'] = "Ingrese aquí el nombre del campo extra de usuario del cual quiere obtener las localizaciones, siga el siguiente link para ver el mapa : " . api_get_path(WEB_PLUGIN_PATH) . "google_maps/src/map_coordinates.php";
+$strings['extra_field_name_help'] = "Ingrese aquí el nombre del campo o los campos extra de usuario separados por una coma (,) del cual quiere obtener las localizaciones, puede obtener hasta 5 campos de geolocalización (el resto serán ignorados) los cuales se marcarán con los siguientes iconos respectivamente:
+
+
+
+siga el siguiente link para ver el mapa : " . api_get_path(WEB_PLUGIN_PATH) . "google_maps/src/map_coordinates.php";
$strings['enable_api'] = "Enable API";
$strings['api_key'] = "Api Key";
$strings['extra_field_name'] = "Extra field name";
-$strings['UsersCoordinatesMap'] = "Users Coordinates Map";
\ No newline at end of file
+$strings['UsersCoordinatesMap'] = "Users location Map";
\ No newline at end of file
diff --git a/plugin/google_maps/lang/french.php b/plugin/google_maps/lang/french.php
index ae386d431c..44f106583d 100644
--- a/plugin/google_maps/lang/french.php
+++ b/plugin/google_maps/lang/french.php
@@ -2,8 +2,12 @@
$strings['plugin_title'] = "Google Maps";
$strings['plugin_comment'] = "Active la fonctionnalité pour afficher Google Maps";
-$strings['extra_field_name_help'] = "Ingrese aquí el nombre del campo extra de usuario del cual quiere obtener las localizaciones, siga el siguiente link para ver el mapa : " . api_get_path(WEB_PLUGIN_PATH) . "google_maps/src/map_coordinates.php";
+$strings['extra_field_name_help'] = "Ingrese aquí el nombre del campo o los campos extra de usuario separados por una coma (,) del cual quiere obtener las localizaciones, puede obtener hasta 5 campos de geolocalización (el resto serán ignorados) los cuales se marcarán con los siguientes iconos respectivamente:
+
+
+
+siga el siguiente link para ver el mapa : " . api_get_path(WEB_PLUGIN_PATH) . "google_maps/src/map_coordinates.php";
$strings['enable_api'] = "Enable API";
$strings['api_key'] = "Api Key";
$strings['extra_field_name'] = "Nom de champ supplémentaire";
-$strings['UsersCoordinatesMap'] = "Carte des coordonnées des utilisateurs";
\ No newline at end of file
+$strings['UsersCoordinatesMap'] = "Carte des emplacement des utilisateurs";
\ No newline at end of file
diff --git a/plugin/google_maps/lang/spanish.php b/plugin/google_maps/lang/spanish.php
index 617953a1ab..018f424418 100644
--- a/plugin/google_maps/lang/spanish.php
+++ b/plugin/google_maps/lang/spanish.php
@@ -2,8 +2,12 @@
$strings['plugin_title'] = "Google Maps";
$strings['plugin_comment'] = "Enable the functionality to show google maps";
-$strings['extra_field_name_help'] = "Ingrese aquí el nombre del campo extra de usuario del cual quiere obtener las localizaciones, siga el siguiente link para ver el mapa : " . api_get_path(WEB_PLUGIN_PATH) . "google_maps/src/map_coordinates.php";
+$strings['extra_field_name_help'] = "Ingrese aquí el nombre del campo o los campos extra de usuario separados por una coma (,) del cual quiere obtener las localizaciones, puede obtener hasta 5 campos de geolocalización (el resto serán ignorados) los cuales se marcarán con los siguientes iconos respectivamente:
+
+
+
+siga el siguiente link para ver el mapa : " . api_get_path(WEB_PLUGIN_PATH) . "google_maps/src/map_coordinates.php";
$strings['enable_api'] = "Activar API";
$strings['api_key'] = "Api Key";
$strings['extra_field_name'] = "Nombre del campo extra";
-$strings['UsersCoordinatesMap'] = "Mapa de Coordenadas de Usuarios";
\ No newline at end of file
+$strings['UsersCoordinatesMap'] = "Mapa de localización de Usuarios";
\ No newline at end of file
diff --git a/plugin/google_maps/src/map_coordinates.php b/plugin/google_maps/src/map_coordinates.php
index 1fba7c6601..8c8856d8aa 100644
--- a/plugin/google_maps/src/map_coordinates.php
+++ b/plugin/google_maps/src/map_coordinates.php
@@ -37,15 +37,28 @@ foreach ($extraFieldName as $field) {
$extraFieldValues = [];
-foreach ($extraFieldNames as $fieldName) {
- $extraFieldRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldValues');
- $extraFieldValues[] = $extraFieldRepo->findBy(['field' => $fieldName->getId()]);
+foreach ($extraFieldNames as $index => $fieldName) {
+ if ($fieldName) {
+ $extraFieldRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldValues');
+ $extraFieldValues[] = $extraFieldRepo->findBy(['field' => $fieldName->getId()]);
+ }
}
$templateName = $plugin->get_lang('UsersCoordinatesMap');
$tpl = new Template($templateName);
+$formattedExtraFieldValues = [];
+
+foreach ($extraFieldValues as $index => $extra) {
+ foreach ($extra as $yandex => $field) {
+ $thisUserExtraField = api_get_user_info($field->getItemId());
+ $formattedExtraFieldValues[$index][$yandex]['address'] = $field->getValue();
+ $formattedExtraFieldValues[$index][$yandex]['user_complete_name'] = $thisUserExtraField['complete_name'];
+ }
+}
+
+$tpl->assign('extra_field_values_formatted', $formattedExtraFieldValues);
$tpl->assign('extra_field_values', $extraFieldValues);
$content = $tpl->fetch('google_maps/view/map_coordinates.tpl');
diff --git a/plugin/google_maps/view/map_coordinates.tpl b/plugin/google_maps/view/map_coordinates.tpl
index 5bde732d7b..a39a8a58cd 100644
--- a/plugin/google_maps/view/map_coordinates.tpl
+++ b/plugin/google_maps/view/map_coordinates.tpl
@@ -6,64 +6,8 @@
initMap();
});
- function addMaker(lat, lng, map, bounds, userInfo, index) {
- if (index > 5) {
- return;
- }
-
- var location = new google.maps.LatLng(lat, lng);
-
- var infoWindow = new google.maps.InfoWindow();
-
- var geocoder = geocoder = new google.maps.Geocoder();
-
- var marker = new google.maps.Marker({
- map: map,
- position: location,
- label: userInfo.complete_name
- });
-
- switch (index) {
- case '1':
- marker.setIcon('//maps.google.com/mapfiles/ms/icons/red-dot.png');
- break;
- case '2':
- marker.setIcon('//maps.google.com/mapfiles/ms/icons/green-dot.png');
- break;
- case '3':
- marker.setIcon('//maps.google.com/mapfiles/ms/icons/blue-dot.png');
- break;
- case '4':
- marker.setIcon('//maps.google.com/mapfiles/ms/icons/yellow-dot.png');
- break;
- case '5':
- marker.setIcon('//maps.google.com/mapfiles/ms/icons/purple-dot.png');
- break;
- }
-
- var address = "";
-
- geocoder.geocode({ 'latLng': location }, function (results) {
-
- if (results) {
- address = results[1].formatted_address;
- } else {
- address = '{{ 'Unknown' | get_lang }}';
- }
-
- var infoWinContent = "" + userInfo.complete_name + " - " + address;
-
- marker.addListener('click', function() {
- infoWindow.setContent(infoWinContent);
- infoWindow.open(map, marker);
- });
- });
-
- bounds.extend(marker.position);
- map.fitBounds(bounds);
- }
-
function initMap() {
+
var center = new google.maps.LatLng(-3.480523, 7.866211);
var bounds = new google.maps.LatLngBounds();
@@ -79,25 +23,83 @@
mapTypeId: google.maps.MapTypeId.ROADMAP
});
- {% for extra in extra_field_values %}
+ var extraFields = {{ extra_field_values_formatted|json_encode }};
- var index = '{{ loop.index }}';
+ for (var i = 0; i < extraFields.length; i++) {
- {% for field in extra %}
+ var index = i + 1;
- var latLng = '{{ field.value }}';
- latLng = latLng.split(',');
+ for (var y = 0; y < extraFields[i].length; y++) {
- var lat = latLng[0];
- var lng = latLng[1];
+ var address = extraFields[i][y]['address'];
+ var userCompleteName = extraFields[i][y]['user_complete_name'];
- {% set userInfo = field.itemId | user_info %}
+ addMaker(address, map, bounds, userCompleteName, index);
+ }
+ }
+ }
- addMaker(lat, lng, map, bounds, {{ userInfo|json_encode }}, index);
+ function addMaker(address, map, bounds, userCompleteName, index) {
- {% endfor %}
+ if (index > 5) {
+ return;
+ }
+
+ var infoWindow = new google.maps.InfoWindow();
- {% endfor %}
+ var geocoder = geocoder = new google.maps.Geocoder();
+ var formattedAddress = '';
+
+ geocoder.geocode({ 'address': address }, function (results, status) {
+
+ if (status === google.maps.GeocoderStatus.OK) {
+
+ if (results) {
+ formattedAddress = results[0].formatted_address;
+ } else {
+ formattedAddress = '{{ 'Unknown' | get_lang }}';
+ }
+
+ var marker = new google.maps.Marker({
+ map: map,
+ position: results[0].geometry.location,
+ label: userCompleteName
+ });
+
+ switch (index) {
+ case 1:
+ marker.setIcon('//maps.google.com/mapfiles/ms/icons/red-dot.png');
+ break;
+ case 2:
+ marker.setIcon('//maps.google.com/mapfiles/ms/icons/green-dot.png');
+ break;
+ case 3:
+ marker.setIcon('//maps.google.com/mapfiles/ms/icons/blue-dot.png');
+ break;
+ case 4:
+ marker.setIcon('//maps.google.com/mapfiles/ms/icons/yellow-dot.png');
+ break;
+ case 5:
+ marker.setIcon('//maps.google.com/mapfiles/ms/icons/purple-dot.png');
+ break;
+ }
+
+ var infoWinContent = "" + userCompleteName + " - " + formattedAddress;
+
+ marker.addListener('click', function() {
+ infoWindow.setContent(infoWinContent);
+ infoWindow.open(map, marker);
+ });
+
+ bounds.extend(marker.position);
+ map.fitBounds(bounds);
+
+ } else if (status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
+ setTimeout(function() {
+ geoCode(address, map, bounds, userCompleteName, index);
+ }, 350);
+ }
+ });
}
\ No newline at end of file