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.964184, 2.557028, "proxiserve-900677ee-9ca9-49e4-840a-e9a5b08e3492"], [48.9293847, 2.3506006, "proxiserve-62500c85-d369-4e63-bba6-aebcef271220"], [43.6153869, 1.4301518, "proxiserve-e65efcef-2a43-41d5-80cb-4ac5521f9e1b"], [44.2485356, 0.64338, "proxiserve-32560632-3897-4381-a375-26877f75cdfa"], [43.3215217, -0.4248718, "33487372602698"], [43.3440489, 3.2540018, "proxiserve-535374b5-8bde-42ad-b5d7-d345fff77c76"], [46.8610813, -1.868096, "33487372602755"], [42.7372725, 2.8886685, "proxiserve-df0501d7-3057-4151-b10d-2df00f6029a4"], [47.2566348, -1.64757, "proxiserve-6762112b-a807-4e7e-a180-12759a2905dd"], [45.9549639, 6.6347026, "honore-pere-et-fils"]]; 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(); });