templates/Map/page.html.twig line 101

Open in your IDE?
  1. {% extends 'grid.html.twig' %}
  2. {% block title %}
  3.     {{ seo_title() }}
  4. {% endblock %}
  5. {% block metaDescription %}
  6.     <meta name="description" content="{{ seo_description() }}">
  7. {% endblock %}
  8. {% block stylesheet %}
  9.     {{ parent() }}
  10.     <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  11. {% endblock %}
  12. {% block name_page %}map{% endblock %}
  13. {% block bodyClasses %}map-page{% endblock %}
  14. {% block mainContainer %}
  15.     {% if city is defined and city.mapCoordinate.latitude %}
  16.         {% set coordss = 1 %}
  17.         {% set lat = city.mapCoordinate.latitude %}
  18.         {% set lon = city.mapCoordinate.longitude %}
  19.     {% else %}
  20.         {% set coordss = 0 %}
  21.         {% set lat = '55.75' %}
  22.         {% set lon = '37.61' %}
  23.     {% endif %}
  24.     <h1 class="border-line">{% if seo_heading() is empty %}%Интим карта{% else %}{{ seo_heading() }}{% endif %}</h1>
  25.     <p class="text-desc mb-lg-4">
  26.         На карте обозначено местоположение зарегистрированных анкет.<br>
  27.         Кликнув на маркер Вы узнаете краткую информацию о девушке.
  28.     </p>
  29.     <div class="map">
  30.         <div class="filter-line d-flex justify-content-center justify-content-md-between mb-2 mb-md-3 mb-lg-4">
  31.             <button class="btn btn-secondary btn-collapse-filter" type="button" id="filter-expand">
  32.                 <svg class="icon mr-1">
  33.                     <use xlink:href="#icon-dropdown"></use>
  34.                 </svg>
  35.                 Расширенный поиск
  36.             </button>
  37.             <div class="d-flex align-items-center collapse-reset ml-2">
  38.                 <span class="d-none" id="count-parameters">Выбрано <em>0</em> параметров</span>
  39.                 <button class="btn btn-secondary btn-collapse-reset ml-md-2" id="reset-form-2" data-reset="true">Сброс</button>
  40.             </div>
  41.         </div>
  42.         <div class="collapse" id="collapseFilter">
  43.         </div>
  44.         <div class="map-wrap loading" id="map-wrap" style="width: 100%; height: 700px;">
  45.         </div>
  46.     </div>
  47.     {# {{ include('components/big_footer.html.twig', { 'type': 'main' }) }} #}
  48.     {{ include('components/seo.partial.twig', {type: 'top'}) }}
  49.     {{ include('components/seo.partial.twig', {type: 'bottom'}) }}
  50. {% endblock %}
  51. {% block javascripts %}
  52.     {{ parent() }}
  53.     {% if city is defined and city.mapCoordinate.latitude %}
  54.         {% set lat = city.mapCoordinate.latitude %}
  55.         {% set lon = city.mapCoordinate.longitude %}
  56.     {% else %}
  57.         {% set lat = '55.753215' %}
  58.         {% set lon = '37.622504' %}
  59.     {% endif %}
  60.     <script src="{{ asset('bundles/fosjsrouting/js/router.min.js') }}" defer></script>
  61.     <script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}" defer></script>
  62.     <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU&onload=initMap&ns=ym" defer></script>
  63.     <script>
  64.         const mapConfig = {
  65.             id:"map-wrap",
  66.             multiple_cities:"{{ multipleCities }}",
  67.             routes_url: "{{ multipleCities == 0 ? '/js/fos_js_routes.json' : '/js/fos_js_routes_city_prefixed.json' }}",
  68.             city_uri_identity:"{{ cityUriIdentity }}",
  69.             city_latitude:"{{ lat }}",
  70.             city_longitude:"{{ lon }}",
  71.             locale:"{{ app.request.locale }}",
  72.             path:"{{ path('map.filter', {city:cityUriIdentity}) }}",
  73.             icon_profile:"{{ asset('assets/images/map/profile.svg') }}",
  74.             icon_profile_active:"{{ asset('assets/images/map/profile-active.svg') }}",
  75.             icon_profile_hover:"{{ asset('assets/images/map/profile-hover.svg') }}",
  76.             icon_saloon:"{{ asset('assets/images/map/saloon.svg') }}",
  77.             icon_saloon_active:"{{ asset('assets/images/map/saloon-active.svg') }}",
  78.             icon_saloon_hover:"{{ asset('assets/images/map/saloon-hover.svg') }}",
  79.             icon_masseur:"{{ asset('assets/images/map/masseur.svg') }}",
  80.             icon_masseur_active:"{{ asset('assets/images/map/masseur-active.svg') }}",
  81.             icon_masseur_hover:"{{ asset('assets/images/map/masseur-hover.svg') }}",
  82.             icon_cluster_small:"{{ asset('assets/images/map/cluster-small.svg') }}",
  83.             icon_cluster_medium:"{{ asset('assets/images/map/cluster-medium.svg') }}",
  84.             icon_cluster_big:"{{ asset('assets/images/map/cluster-big.svg') }}",
  85.             avatar_path : "{{ responsive_asset('replace_path', 'profile_media_avatar', "200x280", "jpg") }}",
  86.             photo_path : "{{ responsive_asset('replace_path', 'profile_media', "200x280", "jpg") }}",
  87.             thumb_path : "{{ responsive_asset('replace_path', 'saloon_media_thumb', "200x280", "jpg") }}",
  88.             process_profile_shows_url  : "{{ path('map.increment_profile_shows', multipleCities ? {city:cityUriIdentity} : {}) }}"
  89.         };
  90.         var isMapInitialized = false;
  91.         var yaMapLoaded = false;
  92.         function initMap() {
  93.             //console.log('initMap');
  94.             window.ymap = new ym.Map(document.getElementById('map-wrap'), {
  95.                 center: ["{{ lat }}", "{{ lon }}"],
  96.                 zoom: 8,
  97.                 controls: ['zoomControl', 'typeSelector',  'fullscreenControl']
  98.             });
  99.             yaMapLoaded = true;
  100.             //if (!isMapInitialized) {
  101.             //    console.log('new mapPage initMap');
  102.             //    isMapInitialized = true;
  103.             //    new MapPage(mapConfig);
  104.             //}
  105.         }
  106.         window.profileShowed = function ({id}) {
  107.             if (!id) return;
  108.             fetch('{{ path('profile_ctr.increase_shows') }}', {
  109.                 method: "POST",
  110.                 body: JSON.stringify({ profiles: [id], source: 'map' }),
  111.             });
  112.         }
  113.         window.stations = {
  114.             {%- for station in stations() -%}{{- station.id -}}:{icon:`{%- include 'components/metro/icon_generate.partial.twig' with {data: station|station_lines} -%}`,name:`{{- station.name -}}`},{%- endfor -%}
  115.         };
  116.         document.addEventListener('DOMContentLoaded', function () {
  117.             function loadForm() {
  118.                 fetch('{{ path('map.form', {city: cityUriIdentity}) }}', {
  119.                     mode: "cors",
  120.                     importance: "low",
  121.                     method: "POST",
  122.                     headers: {
  123.                         "Content-Type": "application/x-www-form-urlencoded",
  124.                         "X-Requested-With": "XMLHttpRequest"
  125.                     },
  126.                 }).then(response => {
  127.                     if (response.status < 300) {
  128.                         return response.text();
  129.                     } else {
  130.                         console.warn("🤔");
  131.                         return null;
  132.                     }
  133.                 }).then(response => {
  134.                     document.getElementById('collapseFilter').innerHTML = response;
  135.                     filterLoader()
  136.                 });
  137.             }
  138.             loadForm();
  139.             function filterLoader() {
  140.                 const stringifyData = `{"city_id":"${document.getElementById('filter_map_form_city_id').value}","_token":"${document.getElementById('filter_map_form__token').value}"}`;
  141.                 fetch("{{ path('map.filter', {city:cityUriIdentity}) }}", {
  142.                     method: "POST",
  143.                     headers: {
  144.                         'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  145.                         'X-Requested-With': 'XMLHttpRequest',
  146.                     },
  147.                     body: new URLSearchParams({ form: stringifyData }).toString(),
  148.                 })
  149.                     .then(response => response.json())
  150.                     .then(data => {
  151.                         //console.log('map-data-loaded')
  152.                         const mapLoadedInterval = setInterval(()=>{
  153.                             if (yaMapLoaded) {
  154.                                 new MapPage(mapConfig);
  155.                                 document.dispatchEvent(new CustomEvent('map:data:loaded', { detail: { data, stringifyData } }));
  156.                                 clearInterval(mapLoadedInterval)
  157.                             }
  158.                         }, 200)
  159.                     })
  160.                     .catch(error => console.error(error));
  161.                 //if (!isMapInitialized) {
  162.                 //    console.log('new mapPage filterLoader');
  163.                 //    isMapInitialized = true;
  164.                 //    new MapPage(mapConfig);
  165.                 //}
  166.             }
  167.         })
  168.     </script>
  169. {% endblock %}