templates/includes/mapa_javascript.html.twig line 1
{% if oficinasMapa is defined %}{% set slug = app.request.attributes.get('slugO') %}<script>function initMap() {const map = new google.maps.Map(document.getElementById("map"), {zoom: {%if oficinasMapa|length > 1%}6{%else%}10{%endif%},center: {%if oficinasMapa|length > 1%}{ lat: 40.4165, lng: -3.70256 }{%elseif oficinasMapa[0].latitud%}{ lat: {{oficinasMapa[0].latitud}}, lng: {{oficinasMapa[0].longitud}} }{%endif%},});var styledMapType = new google.maps.StyledMapType(styleMapDefault);map.mapTypes.set('styled_map', styledMapType);map.setMapTypeId('styled_map');var markers = [];{% for oficina in oficinasMapa %}{% if oficina.latitud and oficina.slug %}{% apply spaceless %}const contentString{{ oficina.id }} ='<div class="card card-mapa" tabindex="0" style="border:none;display: flex;flex-direction: row;"><div class="izq" style="padding: 10px;"><a href="{{ path('ficha_oficina', {slugP: oficina.localidad.provincia.slug, slugL: oficina.localidad.slug, slugO: oficina.slug} ) }}">{% if oficina.imagenMapa %}<img src="{{ sonata_path(oficina.imagenMapa, 'smallN') }}" style="width: fit-content;height: 100%;"/>{% else %}<b>{{ oficina.nombre }}</b>{% endif %}</a></div><div class="der" style="display: flex;flex-direction: column;max-width: 230px;"><img src="/img/logo_azul.svg" style="width: 160px;"/><p style="margin: 0;font-size: 20px;font-weight: bold;color: #1C3264;margin-top: 8px;">{{ oficina.provincia.nombre }}</p><p style="margin-bottom: 10px;font-size: 20px;font-weight: 400;color: #1C3264;">{{ oficina.nombre }}</p>{% if oficina.slug != slug %}<a href="{{ path('ficha_oficina', {slugP: oficina.localidad.provincia.slug, slugL: oficina.localidad.slug, slugO: oficina.slug} ) }}" style="text-decoration: none;font-size: 17px;font-weight: bold;color: #1C3264;"><b>Seleccionar Oficina</b></a>{% else %}<a target="_blank" href="https://www.google.com/maps/dir/Current+Location/{{ oficina.latitud }},{{ oficina.longitud }}" style="text-decoration: none;font-size: 17px;font-weight: bold;color: #1C3264;">{{ '¿Cómo llegar? >' | trans}}</a>{% endif %}</div></div>';{% endapply %}const infowindow{{ oficina.id }} = new google.maps.InfoWindow({content: contentString{{ oficina.id }},});const marker{{ oficina.id }} = new google.maps.Marker({position: { lat: {{ oficina.latitud }}, lng: {{ oficina.longitud }} },map: map,title: '{{ oficina.nombre }}',{# icon: '{{ absolute_url(asset('/img/locMap.svg')) }}' #}icon: {url: '{{ absolute_url(asset('/img/locMap.svg')) }}',scaledSize: new google.maps.Size(50, 60),}});infowindow{{ oficina.id }}.addListener('closeclick', ()=>{});marker{{ oficina.id }}.addListener("click", () => {infowindow{{ oficina.id }}.open({anchor: marker{{ oficina.id }},map,shouldFocus: false,});});markers.push(marker{{ oficina.id }});{% endif %}{% endfor %}var markerCluster = new MarkerClusterer(map, markers,{imagePath: '/img/m'});}</script>{% endif %}