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.8704138, -0.3931551, "igce-immobiliere-generale-de-construction-et-d-entreprise-30849"], [50.5730306, 3.0335149, "ineo-hauts-de-france-1ad676e2-a385-4d5e-8842-e804f14e4c11"], [49.128448, -0.382767, "normandie-bio-logi-k-construction-94afe904-1a2d-4d0f-ac77-ec8f2e9ee326"], [47.2291963, -1.6186887, "bouygues-batiment-grand-ouest-40ca5bc8-e2ec-4b76-9d81-403e1e9222b0"], [49.086682, 6.700472299999999, "fiori-chauffage"], [47.4578982, -0.6037471, "quille-construction-acbf6f7c-db7a-425c-a2ec-8c7e8109d9f3"], [47.7401296, 1.8133188, "groupe-aec"], [48.3861222, -4.4771004, "bouygues-batiment-grand-ouest-9fdbbd8e-5436-4460-97eb-77e3d1f7ad11"], [48.6131643, 2.4920789, "jp-energies"], [43.5466677, 1.4002232, "serclim-toulouse"]]; 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(); });