Sfoglia il codice sorgente

Agregado de funcion para obtener las coordenadas

gabriel 7 anni fa
parent
commit
173dcf4a10
1 ha cambiato i file con 22 aggiunte e 18 eliminazioni
  1. 22 18
      Resources/views/Leaflet/map.html.twig

+ 22 - 18
Resources/views/Leaflet/map.html.twig

@@ -33,25 +33,29 @@
     _MAP_LATITUDE = {{ config_manager.getValueConsume('location', 'location', 'latitude') }};
     _MAP_LONGITUDE = {{ config_manager.getValueConsume('location', 'location', 'longitude') }};
     {% else %}
-    try {
-        $.ajax({
-            url: "{{ path('admin_config_manager_global_ajax') }}",
-            type: 'POST',
-            // async: true,
-            data: {
-                category: "location",
-                setting: "location"
-            }
-        }).done(function (data) {
-            if (data.result) {
-                _MAP_LATITUDE = data.config.latitude;
-                _MAP_LONGITUDE = data.config.longitude;
-            }
-        });
-    } catch (e) {
-        _MAP_LATITUDE = 0;
-        _MAP_LONGITUDE = 0;
+    function setCoordinatesFromConfig() {
+        try {
+            $.ajax({
+                url: "{{ path('admin_config_manager_global_ajax') }}",
+                type: 'POST',
+                // async: true,
+                data: {
+                    category: "location",
+                    setting: "location"
+                }
+            }).done(function (data) {
+                if (data.result) {
+                    _MAP_LATITUDE = data.config.latitude;
+                    _MAP_LONGITUDE = data.config.longitude;
+                }
+            });
+        } catch (e) {
+            _MAP_LATITUDE = 0;
+            _MAP_LONGITUDE = 0;
+        }
     }
+
+    setCoordinatesFromConfig();
     {% endif %}
 </script>
 <script src="{{ asset('bundles/leaflet/js/leaflet-map.js') }}"></script>