Browse Source

Cargo la latitud y longitud

gabriel 7 years ago
parent
commit
00a5d9ca42
1 changed files with 23 additions and 4 deletions
  1. 23 4
      Resources/views/Leaflet/map.html.twig

+ 23 - 4
Resources/views/Leaflet/map.html.twig

@@ -27,12 +27,31 @@
 {% endif %}
 
 <script type="application/javascript">
-    {% if config_manager is defined %}
-    var _MAP_LATITUDE = {{ config_manager.getValue('location', 'location', 'latitude') }};
-    var _MAP_LONGITUDE = {{ config_manager.getValue('location', 'location', 'longitude') }};
-    {% else %}
     var _MAP_LATITUDE = 0;
     var _MAP_LONGITUDE = 0;
+    {% if config_manager is defined %}
+    _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;
+    }
     {% endif %}
 </script>
 <script src="{{ asset('bundles/leaflet/js/leaflet-map.js') }}"></script>