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 = [[47.3815743, 0.7620226, "portalp-france-5d374a28-3d7f-4bbd-9cc3-4d9a47e5cff8"], [47.0170608, -1.3457966, "solewa-98a283f8-12cf-4c86-9a73-8e2f16b3a6c1"], [43.6643328, 2.2927402, "weber-jonathan-kevin-a18ebf88-5452-4129-bebb-7e3bcae64665"], [43.6641293, 2.2926768, "weber-jonathan-kevin-86effcbe-0f76-4203-85aa-98db8d99d2a0"], [43.4937902, 2.333083, "weber-jonathan-kevin-44f1385a-0d84-41a7-808e-039d3c148d92"], [45.460294, -0.2430939999999999, "bretin-jean-louis-henri"], [47.7322617, -3.4243066, "spie-industrie-e9d30d48-5e7d-4281-8b3d-c5a0184d6842"], [50.4076737, 2.9829391, "spie-industrie-46d9649e-e01a-4b2f-a728-16f484273645"], [47.7519508, 7.316791200000001, "spie-industrie-d5bc3047-5afa-4aa5-a027-9aabafb483a8"], [43.56103239999999, 3.8425906, "spie-industrie-7d1ce394-4f5b-4f76-971b-df3fccf380b6"]]; 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(); });