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.0815453, -1.6776428, "bouygues-batiment-grand-ouest-8d881b0b-22a6-45c2-8ae6-36e838fecbc2"], [47.7894873, -3.3170405, "bouygues-batiment-grand-ouest-978762e7-dd4c-4c65-9a23-9ddd1d1400e7"], [47.388593, 2.87503, "92124249100014"], [44.9174606, -0.4821723, "m-g-b-00904ddc-371e-4c73-88e3-e3831f22f1db"], [48.7445347, 2.3514889, "electricim"], [47.974581, 0.168385, "eiffage-energie-systemes-clemessy-ea77cc0e-0125-43de-9466-5e44e3385e28"], [43.7694947, 3.9564107, "pro-energies-58122"], [47.214772, 0.164985, "eiffage-energie-systemes-clemessy-ec6b331a-6899-4922-9428-5358852c36d5"], [47.1933257, -1.5612773, "eiffage-energie-systemes-clemessy-59277ba0-251e-4e35-b292-9dc1b7fa8e2b"], [45.71859200000001, 1.552767, "debien-entreprise"]]; 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(); });