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.4320276, 1.0738659, "monument-lanfry-ade99383-130e-4345-b15a-c0a891e26d87"], [43.4717782, 6.5662969, "innovation-toit-et-bois-3eed64bd-e7e9-4112-a379-02285989d8bc"], [43.6866326, 7.183907199999999, "axe-btp-60bfe5ee-4bed-49bb-b6d4-c85a82bfa853"], [46.3068839, 4.828730999999999, "94768409800017"], [45.6648709, 4.964496599999999, "soler-renovations-avenir-renovations"], [45.8842779, 1.2794976, "proxiserve-04a68b07-19ba-41a0-ade8-dc1a11cbe688"], [48.2745419, 3.976156, "isostores-3-49495"], [45.1436602, 5.6901255, "proxiserve-57ac06fc-1c5a-41c7-86a3-ccda912b24db"], [44.1618319, 4.239255, "ep-menuiseries-39206"], [45.0501231, 3.897140099999999, "proxiserve-8a25dd3f-cbbb-48d1-a1cf-decf12923cbe"]]; 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(); });