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 = [[45.93883719999999, 6.6319646, "megevand-chauffage-sarl"], [51.0362387, 2.3455534, "provalibat-6adccba7-b41a-4b81-a082-ece1136f4766"], [46.7859099, 1.6521087, "g-mauve-sas-42899"], [50.736113, 2.470899, "cleenewerck-chauffage-5ad3df1b-aa61-4d6f-9770-e8012171e95d"], [43.6375496, 1.4969897, "nrgeo-4377"], [44.3387519, 3.5892945, "garcia-tavares-alfredo"], [43.5963807, 6.4510932, "poletto-sebastien-dominique-7e7910ac-4cf4-460e-9eba-87742ffe5b5e"], [47.2908493, -2.3026345, "mas-menuiserie-amenagement-simon"], [47.8150447, 6.3555824, "totalenergies-proxi-nord-est-62f122c7-0131-4f67-9e38-4d47653d26c3"], [43.6466573, 1.467715, "stbat-386c5b2b-7810-4ee2-8782-0db248bdd51e"]]; 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(); });