Accueil Assets
function initMap() { var bounds = new google.maps.LatLngBounds(); var map = new google.maps.Map(document.getElementById('artisans-map'), { styles: styleMap }); var icon = { url: "https://artisans.quelleenergie.fr/assets/icones/geolocalize-02-57f71366ba86f935cf6949b551c67cc17042750d0fc34a5d7af80ac028bfae86.svg", scaledSize: new google.maps.Size(40, 40) } var iconSelectionne = { url: "https://artisans.quelleenergie.fr/assets/icones/geolocalize-01-5fe26a2a4ce9fd6566cc27b4fabb592a37fa7722f3e3d73019830ede8c4dbd05.svg", scaledSize: new google.maps.Size(40, 40) } var markers = [[49.8527145, 1.8227763, "sannier-moule-industriel"], [47.0019865, 0.0751274, "bourdon-36207"], [47.0782263, 5.413954899999999, "fermoconseil-37470"], [48.5307026, -2.040758, "tecni-logis-agence-981a749e-106b-42ee-b1cd-68f12fead870"], [44.8780844, 2.3848911, "90479826100015"], [48.6900649, -1.369603, "tecni-logis-agence-f26b358a-24a2-4634-9503-648c18297c54"], [47.8535283, -1.6845386, "tecni-logis-cd5d22ee-1c27-48e6-a031-87db72f4217c"], [48.4220106, -4.4608814, "tecni-logis-2cba8cee-dbee-4b42-91ec-7d8713035f9e"], [47.171628, -1.3565799, "dlmbat-f9cc4e7e-aed7-4087-acc5-0663c9f961b0"], [43.64463870000001, 1.4554071, "amarenco-construction-2e4d9750-8244-48da-9b50-4d45196c9e7d"]]; var dernierMarkerSelectionne; var listeObjetMarkers = [] for( i = 0; i < markers.length; i++ ) { var position = new google.maps.LatLng(markers[i][0], markers[i][1]); bounds.extend(position); marker = new google.maps.Marker({ position: position, map: map, url: markers[i][2], icon: icon }); listeObjetMarkers.push(marker) google.maps.event.addListener(marker, 'click', function() { montreCardArtisan(this); }); } map.fitBounds(bounds) map.panToBounds(bounds) $('.artisans-container .artisan-item').hover(function(){ montrePositionArtisan($(this)); }); function deselectionneMarker() { if (dernierMarkerSelectionne != undefined) { dernierMarkerSelectionne.setIcon(icon); } } function selectionneMarker(element) { $('.artisan-item.selectionne').removeClass('selectionne') element.toggleClass('selectionne') } function montreCardArtisan(marker) { deselectionneMarker(); marker.setIcon(iconSelectionne); var element = $('#'+marker.url); $('html, body').animate({ scrollTop: element.offset().top }, 600 ); selectionneMarker(element); dernierMarkerSelectionne = marker } function montrePositionArtisan(element) { selectionneMarker(element) var index = element.attr('id') for( i = 0; i < markers.length; i++ ) { if (listeObjetMarkers[i].url == index) { deselectionneMarker(); listeObjetMarkers[i].setIcon(iconSelectionne); dernierMarkerSelectionne = listeObjetMarkers[i] } }; } } $(document).on('turbolinks:load', function () { initMap(); });