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 = [[48.1874102, -1.7237976, "tecni-logis-agence-41700bb6-2b41-4834-889b-103de1314d32"], [48.6192171, 0.5389339, "l-atelier-du-bois-42914"], [44.6113434, -1.1310483, "engie-home-services-78d19770-4ffc-4a0f-bc42-b126c2cfbe26"], [46.7944418, 4.8140144, "lembelembe-sylvain-moutombo"], [48.9037496, 2.3592475, "eurogem-14c6418c-fdc0-4777-8476-29e6f84c98a3"], [48.9104641, 2.368007, "eurogem-d064b7b0-f77b-4703-b6ab-0380ed83598c"], [45.5150971, 4.8643377, "84912123100021"], [43.4366826, 5.4038131, "eurogem-6891d9dd-7f68-45a0-b92e-191a00e0525f"], [49.4826454, 1.0219271, "eurogem-8ff79ced-fc0b-461b-b5fd-dabf60943f9d"], [47.3422515, 5.0619558, "eurogem-fec85e33-4a5f-41ee-b417-e04ec9b1d83b"]]; 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(); });