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 = [[44.872456, -0.6504956, "eneria-a9fad259-ea9d-43a6-9ce3-898221c7d2d4"], [48.9278042, 2.34269, "eneria-35ea640f-fbee-4a04-b075-ad49d7f6c285"], [49.4872187, 0.1460296, "81172058000059"], [43.49248, 5.52714, "eneria-8925cdaf-191a-46f5-b3b8-59204db33b73"], [43.021485, 3.038135, "eneria-d0bef62f-f627-41c5-ba0c-b305d818dfd2"], [47.3267983, -2.4022751, "eneria-0706d4c3-96fe-486b-9514-11dabc6af378"], [48.6890964, -3.3672075, "opi-35000"], [48.341212, -2.664373, "opi-1b7ed8f6-9a2f-4a0a-81c0-89a8ab397d81"], [43.3329512, 0.0978787, "mazenq-christophe-abf2c1c4-3881-475e-850c-a7a10c7cccad"], [49.1451703, 1.1467758, "etablissements-lang-61ad13ef-70b4-4f96-a147-58aed36930c8"]]; 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(); });