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.9197995, 4.928062499999999, "constructel-constructions-telecommunica-749cd5bc-b112-469d-aa92-e26c92ef491c"], [45.0472581, 0.9779918, "bouygues-energies-services-f2c24905-7cfb-463a-8f03-8afd5fb7dfe1"], [47.3239813, -2.4063191, "bouygues-energies-services-d01dbead-19f3-400c-89f6-0aef2550181d"], [47.35487879999999, -1.9445471, "bouygues-energies-services-bdda5f61-9adf-4732-86b6-63a6a14dd50e"], [48.7234433, 2.2829599, "bouygues-energies-services-6331f555-9561-474f-99de-180a852ecaad"], [48.7417465, 6.1584623, "eurl-finition-carree-ea84cbf3-f716-4975-b42d-66d6b9dc9865"], [43.6677088, 1.366145, "temsol-b465646b-2f7f-48c2-8b7e-ec8c35b7c9ac"], [45.7844178, 3.1289071, "temsol-fc44f709-8b7b-4f57-9772-8319a733c0b0"], [46.1711398, -1.0677779, "t-m-constructions"], [45.8463047, 5.435164599999999, "antonino-montarello-22954"]]; 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(); });