map.html.twig 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <div id="map" class="leaflet-map-widget"></div>
  2. <style type="text/css">
  3. .leaflet-map-widget {
  4. height: 400px;
  5. border: 1px solid #CCCCCC;
  6. }
  7. .leaflet-control-search.search-exp.leaflet-control {
  8. width: 400px !important;
  9. }
  10. .search-input {
  11. width: 370px !important;
  12. }
  13. </style>
  14. {% include 'LeafletBundle:Leaflet:resources.html.twig' %}
  15. {% if object is defined %}
  16. <script type="text/javascript">
  17. {% if object.location.extraData is defined %}
  18. var dataValue = '{{ object.location.extraData|raw }}';
  19. {% elseif object.extraData is defined %}
  20. var dataValue = '{{ object.extraData|raw }}';
  21. {% endif %}
  22. </script>
  23. {% endif %}
  24. <script type="application/javascript">
  25. var _MAP_LATITUDE = 0;
  26. var _MAP_LONGITUDE = 0;
  27. {% if config_manager is defined %}
  28. _MAP_LATITUDE = {{ config_manager.getValueConsume('location', 'location', 'latitude') }};
  29. _MAP_LONGITUDE = {{ config_manager.getValueConsume('location', 'location', 'longitude') }};
  30. {% else %}
  31. function setCoordinatesFromConfig() {
  32. try {
  33. $.ajax({
  34. url: "{{ path('admin_config_manager_global_ajax') }}",
  35. type: 'POST',
  36. // async: true,
  37. data: {
  38. category: "location",
  39. setting: "location"
  40. }
  41. }).done(function (data) {
  42. if (data.result) {
  43. _MAP_LATITUDE = data.config.latitude;
  44. _MAP_LONGITUDE = data.config.longitude;
  45. }
  46. });
  47. } catch (e) {
  48. _MAP_LATITUDE = 0;
  49. _MAP_LONGITUDE = 0;
  50. }
  51. }
  52. setCoordinatesFromConfig();
  53. {% endif %}
  54. </script>
  55. <script src="{{ asset('bundles/leaflet/js/leaflet-map.js') }}"></script>
  56. {% if draw is defined %}
  57. <script src="{{ asset('bundles/leaflet/js/leaflet-map-draw.js') }}"></script>
  58. {% endif %}
  59. {% if extra_js is defined %}
  60. <script src="{{ script_google_maps }}"></script>
  61. <script src="{{ asset('bundles/leaflet/js/leaflet-map-widget.js') }}"></script>
  62. {% endif %}