templates/Map/page.html.twig line 1

Open in your IDE?
  1. {% extends '__design/v2023/grid-map.html.twig' %}
  2. {% block preconnect %}
  3.     {{ parent() }}
  4.     <link rel="preconnect" href="https://yastatic.net">
  5.     <link rel="preconnect" href="https://api-maps.yandex.ru">
  6. {% endblock %}
  7. {# {% block stylesheet_postload %}{{ encore_entry_link_tags("styles/public-map-page") }}{{ parent() }} #}
  8.     {# <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">{% endblock %} #}
  9. {% block wrapper_class %} wrapper--map{% endblock %}
  10. {% block mainContainer %}
  11.     {# {{- knp_menu_render('breadcrumbs', {'template': '__design/v2023/_menu/breadcrumbs.html.twig' }) -}} #}
  12.     <h1 class="d-none">{{ seo_heading() ? seo_heading() : 'Интим карта' }}</h1>
  13.     <div class="map-page content">
  14.         <div class="map-heading container">
  15.             <button class="map-back btn btn-transparent" type="button" onclick="history.back()">
  16.                 <svg class="btn-icon" width="24" height="24" viewBox="0 0 24 24"><path fill="#2C2C2C" d="m17.83 20.13-1.77 1.77-9.9-9.9 9.9-9.9 1.77 1.77L9.7 12l8.13 8.13Z"/></svg>
  17.                 <span class="btn-text">Назад</span>
  18.             </button>
  19.             <button class="map-btn btn btn-grey" type="button" data-a11y-dialog-show="filter-dialog">
  20.                 <svg class="btn-icon" width="20" height="20" viewBox="0 0 20 20"><path d="M7.5 4.165a.833.833 0 1 0 0 1.666.833.833 0 0 0 0-1.666Zm-2.358 0a2.5 2.5 0 0 1 4.717 0h5.975a.833.833 0 1 1 0 1.666H9.859a2.5 2.5 0 0 1-4.717 0h-.975a.833.833 0 1 1 0-1.666h.975Zm7.359 5a.833.833 0 1 0 0 1.666.833.833 0 0 0 0-1.666Zm-2.359 0a2.501 2.501 0 0 1 4.717 0h.975a.833.833 0 1 1 0 1.667h-.975a2.502 2.502 0 0 1-4.717 0H4.167a.833.833 0 1 1 0-1.667h5.975Zm-2.641 5a.833.833 0 1 0 0 1.666.833.833 0 0 0 0-1.666Zm-2.359 0a2.5 2.5 0 0 1 4.717 0h5.975a.833.833 0 1 1 0 1.667H9.859a2.501 2.501 0 0 1-4.717 0h-.975a.833.833 0 1 1 0-1.667h.975Z"/></svg>
  21.                 <span class="btn-text">Фильтры</span>
  22.             </button>
  23.         </div>
  24.         <div class="map-wrap skeleton skeleton--map loading" id="map-wrap"></div>
  25.     </div>
  26. {% endblock %}
  27. {%- block javascripts -%}
  28.     {{ parent() }}
  29.     {% if city is defined and city.mapCoordinate.latitude %}
  30.         {% set lat = city.mapCoordinate.latitude %}
  31.         {% set lon = city.mapCoordinate.longitude %}
  32.     {% else %}
  33.         {% set lat = '55.753215' %}
  34.         {% set lon = '37.622504' %}
  35.     {% endif %}
  36.     <script src="{{ asset('bundles/fosjsrouting/js/router.min.js') }}" defer></script>
  37.     <script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}" defer></script>
  38.     <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU&onload=initMap&ns=ym" defer></script>
  39.     <script>
  40.         const mapConfig = {
  41.             id:"map-wrap",
  42.             multiple_cities:"{{ multipleCities }}",
  43.             routes_url: "{{ multipleCities == 0 ? '/js/fos_js_routes.json' : '/js/fos_js_routes_city_prefixed.json' }}",
  44.             city_uri_identity:"{{ cityUriIdentity }}",
  45.             city_latitude:"{{ lat }}",
  46.             city_longitude:"{{ lon }}",
  47.             locale:"{{ app.request.locale }}",
  48.             path:"{{ path('map.filter', {city:cityUriIdentity}) }}",
  49.             icon_profile:"{{ asset('assets/images/map/profile.svg') }}",
  50.             icon_profile_active:"{{ asset('assets/images/map/profile-active.svg') }}",
  51.             icon_profile_hover:"{{ asset('assets/images/map/profile-hover.svg') }}",
  52.             icon_saloon:"{{ asset('assets/images/map/saloon.svg') }}",
  53.             icon_saloon_active:"{{ asset('assets/images/map/saloon-active.svg') }}",
  54.             icon_saloon_hover:"{{ asset('assets/images/map/saloon-hover.svg') }}",
  55.             icon_masseur:"{{ asset('assets/images/map/masseur.svg') }}",
  56.             icon_masseur_active:"{{ asset('assets/images/map/masseur-active.svg') }}",
  57.             icon_masseur_hover:"{{ asset('assets/images/map/masseur-hover.svg') }}",
  58.             icon_cluster_small:"{{ asset('assets/images/map/cluster-small.svg') }}",
  59.             icon_cluster_medium:"{{ asset('assets/images/map/cluster-medium.svg') }}",
  60.             icon_cluster_big:"{{ asset('assets/images/map/cluster-big.svg') }}",
  61.             avatar_path : "{{ responsive_asset('replace_path', 'profile_media_avatar', "200x280", "jpg") }}",
  62.             photo_path : "{{ responsive_asset('replace_path', 'profile_media', "200x280", "jpg") }}",
  63.             thumb_path : "{{ responsive_asset('replace_path', 'saloon_media_thumb', "200x280", "jpg") }}",
  64.             process_profile_shows_url  : "{{ path('map.increment_profile_shows', multipleCities ? {city:cityUriIdentity} : {}) }}"
  65.         };
  66.         var isMapInitialized = false;
  67.         var yaMapLoaded = false;
  68.         function initMap() {
  69.             //console.log('initMap');
  70.             window.ymap = new ym.Map(document.getElementById('map-wrap'), {
  71.                 center: ["{{ lat }}", "{{ lon }}"],
  72.                 zoom: 8,
  73.                 controls: ['zoomControl', 'typeSelector',  'fullscreenControl']
  74.             });
  75.             yaMapLoaded = true;
  76.             //if (!isMapInitialized) {
  77.             //    console.log('new mapPage initMap');
  78.             //    isMapInitialized = true;
  79.             //    new MapPage(mapConfig);
  80.             //}
  81.         }
  82.         window.profileShowed = function ({id}) {
  83.             if (!id) return;
  84.             fetch('{{ path('profile_ctr.increase_shows') }}', {
  85.                 method: "POST",
  86.                 body: JSON.stringify({ profiles: [id], source: 'map' }),
  87.             });
  88.         }
  89.         window.stations = {
  90.             {%- for station in stations() -%}{{- station.id -}}:{icon:`{%- include 'components/metro/icon_generate.partial.twig' with {data: station|station_lines} -%}`,name:`{{- station.name -}}`},{%- endfor -%}
  91.         };
  92.         document.addEventListener('DOMContentLoaded', function () {
  93.             function loadForm() {
  94.                 fetch('{{ path('map.form', {city: cityUriIdentity}) }}', {
  95.                     mode: "cors",
  96.                     importance: "low",
  97.                     method: "POST",
  98.                     headers: {
  99.                         "Content-Type": "application/x-www-form-urlencoded",
  100.                         "X-Requested-With": "XMLHttpRequest"
  101.                     },
  102.                 }).then(response => {
  103.                     if (response.status < 300) {
  104.                         return response.text();
  105.                     } else {
  106.                         console.warn("🤔");
  107.                         return null;
  108.                     }
  109.                 }).then(response => {
  110.                     document.getElementById('dialog-form').innerHTML = response;
  111.                     filterLoader()
  112.                 });
  113.             }
  114.             loadForm();
  115.             function filterLoader() {
  116.                 const stringifyData = `{"city_id":"${document.getElementById('filter_map_form_city_id').value}","_token":"${document.getElementById('filter_map_form__token').value}"}`;
  117.                 fetch("{{ path('map.filter', {city:cityUriIdentity}) }}", {
  118.                     method: "POST",
  119.                     headers: {
  120.                         'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  121.                         'X-Requested-With': 'XMLHttpRequest',
  122.                     },
  123.                     body: new URLSearchParams({ form: stringifyData }).toString(),
  124.                 })
  125.                     .then(response => response.json())
  126.                     .then(data => {
  127.                         //console.log('map-data-loaded')
  128.                         const mapLoadedInterval = setInterval(()=>{
  129.                             if (yaMapLoaded) {
  130.                                 new MapPage(mapConfig);
  131.                                 document.dispatchEvent(new CustomEvent('map:data:loaded', { detail: { data, stringifyData } }));
  132.                                 clearInterval(mapLoadedInterval)
  133.                             }
  134.                         }, 200)
  135.                     })
  136.                     .catch(error => console.error(error));
  137.                 //if (!isMapInitialized) {
  138.                 //    console.log('new mapPage filterLoader');
  139.                 //    isMapInitialized = true;
  140.                 //    new MapPage(mapConfig);
  141.                 //}
  142.             }
  143.         })
  144.     </script>
  145. {% endblock %}
  146. {% block modal %}
  147.     {{- parent() -}}
  148.     {{- include('__design/v2023/components/modal/filter.html.twig') -}}
  149. {% endblock %}