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 = [[43.3437218, 5.3640623, "engie-home-services-95780704-6d1c-42e1-93b6-c04f1831903e"], [48.7063155, 6.2505239, "engie-home-services-ed94ce64-1b26-49ca-aadb-64694ac703ae"], [47.17559809999999, -1.6172271, "engie-home-services-f232ecc6-c9ad-4f7f-afff-2118225d8c32"], [46.1594161, -1.1034618, "engie-home-services-4eb3ae44-d3d8-4179-9068-bcb9c8208250"], [43.72879760000001, 7.267879999999999, "engie-home-services-fe5d554d-a2c0-42c9-bd82-678f9d325515"], [44.8587052, 0.4954989, "30134058407033"], [47.2641385, 6.0573186, "30134058407041"], [48.4321507, 0.0559406, "30134058407074"], [48.8242752, 2.3523255, "engie-home-services-62228a8d-0e02-46c4-b3f3-856f9c1f2254"], [43.3188741, 5.5847695, "engie-home-services-e40020af-b0ca-4531-b81a-202bd17cec64"]]; 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(); });