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.3976715, 4.7748307, "rhone-alpes-facades-763c0454-1e85-426d-aeb5-ffe41872958d"], [48.0136043, 0.1634171, "quille-construction-bea08c5a-bce0-422e-8b92-21c58e03e1d5"], [49.86012600000001, 2.278531, "quille-construction-5c16aee1-d9c1-482f-8162-1b7e3527a97e"], [49.4478963, 2.0994221, "bouygues-batiment-grand-ouest-0580f60c-e68a-4d06-96a6-240a5c4fee27"], [46.4734471, -0.837046, "venant-sarl-12188"], [49.4333783, 1.0748866, "bouygues-batiment-grand-ouest-80d54e9b-0ce3-4146-bf0f-3e7637c6b365"], [46.16876569999999, 5.0330596, "98082049200018"], [46.4475289, 4.1037381, "alhena-secteur-charolais-bourbonnais"], [45.964382, 2.201377, "sanchez-philippe"], [44.09311839999999, 3.551441, "pialot-nicolas-51815"]]; 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(); });