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 = [[46.001377, 6.121991, "sademo-sas"], [45.2609939, -0.244065, "jobert-pascal"], [45.524275, 5.083364, "lovisolo-sarl-26031"], [43.18398819999999, 0.0748484, "construction-maisons-a-p-j-9aba1531-4438-4b79-bc6b-a9f1a518f0cb"], [50.3713671, 3.4985724, "mjp"], [45.72086770000001, 4.6992367, "societe-nouvelle-de-carrelage-s-n-c-25396"], [47.2790737, 5.011072299999999, "ivt-security-bf4205f6-34e3-48dd-8bba-5c13119a9cb8"], [41.8937544, 8.8072831, "89126622300017"], [49.1163651, 6.235683499999999, "eiffage-energie-systemes-lorraine-marne-ardennes-c7c66347-b4df-44e6-bff9-34be1cb201fc"], [49.2436861, 3.9177827, "eiffage-energie-systemes-lorraine-marne-ardennes-dee6b499-a5dc-4fe7-9120-540d8797f24d"]]; 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(); });