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.091816, -1.7871776, "spie-industrie-82ab1c63-a42b-48ca-afd7-a4127f51ea8d"], [48.5608289, -3.860971999999999, "spie-industrie-cfe8a723-544c-4bc6-bc7e-e11ba6fb2e58"], [43.235751, -1.046747, "barbaste-jerome-23849"], [48.4286425, -4.4490718, "spie-industrie-c5a9d726-2507-48a7-bf18-77afc78cd552"], [48.10043899999999, -0.7547929999999999, "spie-industrie-734434ee-84a6-4977-98bd-0d61de8e1a9e"], [48.8363691, 2.3950628, "mvms-architectes"], [47.7288686, -3.425381, "spie-industrie-5726e628-c613-44df-acc8-84a122cb7dfc"], [45.837158, 3.118112, "spie-industrie-f226575a-fda2-4395-8e42-9584b104dd9a"], [46.7929147, 4.4556764, "spie-industrie-dda901c1-cdaa-45fb-9774-fc80e6a01e29"], [43.364587, -0.38381, "spie-industrie-a1617183-4f86-49f7-b40a-82c7e57e5f3b"]]; 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(); });