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 = [[49.160148, -0.326564, "portalp-france-02ebe85a-d716-4766-aad9-e31caf5c858d"], [44.5989651, -0.3260654, "51215636500037"], [48.83765229999999, 2.2886509, "soe-stuc-et-staff"], [48.55979, -2.8108151, "spie-industrie-1067e829-3792-4780-a261-9d7304958c69"], [48.57678, -2.05855, "spie-industrie-3d81e763-7f2a-4a0c-86f3-1fd0c45fa7a7"], [47.915541, 1.941065, "84460672300147"], [45.13749019999999, 5.7103249, "spie-industrie-e9b6eb99-9bfa-4665-b3d5-fe582749623c"], [45.8805377, 3.1211988, "spie-industrie-c8eecb57-d59c-4a35-810c-f9b5805c071b"], [43.493123, 5.3456214, "spie-industrie-529783a4-7388-4b85-85b5-7972cd245ff0"], [46.3831857, 6.508719699999999, "spie-industrie-250ea5c8-a9dd-430e-bebb-c906ab84aeb2"]]; 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(); });