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.9203288, 2.2343613, "energiz-air-81360250-702b-415a-92f7-0ea3d3cc7e9e"], [43.82054919999999, 4.4636892, "e-t-e"], [48.8140468, 2.3964266, "sade-ge-063e9555-078b-42c0-9f27-c34bc5c26e15"], [48.302687, -0.243279, "proclair-36500"], [48.4320964, 0.0710538, "proclair-22e95acf-fa63-4c91-aba9-058304274463"], [48.0012649, 0.183708, "proclair-2f1d3cef-6390-49c9-bcb0-c7c71e64da60"], [49.42003940000001, 1.1065743, "sade-cgth"], [48.3021171, -0.6135592, "proclair-fb641a1e-7a15-4c35-8529-bee48d492d75"], [46.0580408, 5.8680696, "rannard-freres-etablissement"], [43.2131072, 2.3075229, "sade-compagnie-generale-de-travaux-hydrauliques-e07d16bc-c5af-4d45-afb5-0edf69ce3c5b"]]; 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(); });