720 lines
25 KiB
Vue
720 lines
25 KiB
Vue
<template>
|
||
<section class="portraits-eleveur">
|
||
<div class="portraits">
|
||
<div v-if="isOCB" class="txtLegende">
|
||
<h3>
|
||
{{ __('Découvrez les portraits des éleveurs partenaires :ocbType' , {
|
||
'ocbType': ocbType.label
|
||
}) }}
|
||
<picture>
|
||
<source :srcset="asset('assets/images/ocb/logo-oui-contour.webp')" type="image/webp"/>
|
||
<img :src="asset('assets/images/ocb/logo-oui-contour.png')" :alt="__('Oui c\'est Bon !')"/>
|
||
</picture>
|
||
</h3>
|
||
<p>
|
||
{{ __('Tous les élevages') }}
|
||
<picture>
|
||
<source :srcset=" asset('assets/images/gmap/icon-oui-mobile.webp')" type="image/webp" />
|
||
<img :src=" asset('assets/images/gmap/icon-oui-mobile.png')" alt="OCB" />
|
||
</picture>
|
||
{{ __('sont situés à moins de 200km de nos sites de préparation') }}
|
||
<picture>
|
||
<source :srcset=" asset('assets/images/ocb/site-oui-mobile.webp')" type="image/webp" />
|
||
<img :src=" asset('assets/images/ocb/site-oui-mobile.png')" alt="OCB" />
|
||
</picture>.
|
||
</p>
|
||
<h5 ref="clickOn">{{ __('Cliquez sur les marqueurs verts pour en savoir plus sur les éleveurs partenaires.') }}</h5>
|
||
</div>
|
||
<div v-if="!isOCB" class="txtLegende">
|
||
<h3>{{__('Quelques portraits des éleveurs partenaires partout en France') }}</h3>
|
||
<h5 ref="clickOn">{{__('Cliquez sur les marqueurs rouges pour en savoir plus sur les éleveurs partenaires.') }}</h5>
|
||
</div>
|
||
<div ref="blocEleveur" class="blocEleveur display-none">
|
||
<div ref="infoEleveur" :class="'infoEleveur '+(isOCB ? 'ocb' : '')">
|
||
<span @click="closeBlockEleveur()" class="info-close-btn"><i class="far fa-times-circle"></i></span>
|
||
<img ref="image" src="" alt="" />
|
||
<div class="txtEleveur">
|
||
<h4 ref="title"></h4>
|
||
<h6 ref="subtitle"></h6>
|
||
<p ref="content"></p>
|
||
</div>
|
||
<a v-if="isOCB" ref="link" href="#">{{ __('En Savoir +') }}</a>
|
||
</div>
|
||
</div>
|
||
<div id="map" ref="map"></div>
|
||
</div>
|
||
</section>
|
||
</template>
|
||
|
||
<script>
|
||
|
||
export default {
|
||
mounted() {
|
||
// Hook for Google Api
|
||
window.initMap = this.initMap
|
||
// Hook For OMS
|
||
window.initMarkers = this.initMarkers
|
||
if(this.dataOcbType) {
|
||
this.ocbType = JSON.parse(this.dataOcbType)
|
||
this.isOCB = true
|
||
}
|
||
},
|
||
props: [
|
||
'dataOcbType'
|
||
],
|
||
data() {
|
||
return {
|
||
isOCB: false,
|
||
ocbType: {},
|
||
hasInitMap: false,
|
||
hasInitMarkers: false,
|
||
map: null,
|
||
mapOptions: {
|
||
center: null,
|
||
zoom: 3,
|
||
zoomControl: true,
|
||
mapTypeControl: false,
|
||
streetViewControl: false,
|
||
fullscreenControl: false,
|
||
scrollwheel: false,
|
||
draggable: true,
|
||
styles: [
|
||
{
|
||
"featureType": "administrative",
|
||
"elementType": "labels.text.fill",
|
||
"stylers": [
|
||
{
|
||
"color": "#444444"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "administrative.country",
|
||
"elementType": "all",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "administrative.province",
|
||
"elementType": "all",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "administrative.neighborhood",
|
||
"elementType": "all",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "landscape",
|
||
"elementType": "all",
|
||
"stylers": [
|
||
{
|
||
"color": "#f2f2f2"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "landscape.man_made",
|
||
"elementType": "labels.text.fill",
|
||
"stylers": [
|
||
{
|
||
"lightness": "0"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "poi",
|
||
"elementType": "all",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "road",
|
||
"elementType": "all",
|
||
"stylers": [
|
||
{
|
||
"saturation": -100
|
||
},
|
||
{
|
||
"lightness": 45
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "road.highway",
|
||
"elementType": "all",
|
||
"stylers": [
|
||
{
|
||
"visibility": "simplified"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "road.highway",
|
||
"elementType": "labels",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "road.highway.controlled_access",
|
||
"elementType": "labels",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "road.arterial",
|
||
"elementType": "geometry.stroke",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "road.arterial",
|
||
"elementType": "labels",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "road.arterial",
|
||
"elementType": "labels.text.fill",
|
||
"stylers": [
|
||
{
|
||
"lightness": "-63"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "road.arterial",
|
||
"elementType": "labels.text.stroke",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "road.arterial",
|
||
"elementType": "labels.icon",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "road.local",
|
||
"elementType": "all",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "transit",
|
||
"elementType": "all",
|
||
"stylers": [
|
||
{
|
||
"visibility": "off"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"featureType": "water",
|
||
"elementType": "all",
|
||
"stylers": [
|
||
{
|
||
"visibility": "on"
|
||
},
|
||
{
|
||
"color": "#92c0d3"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
},
|
||
oms: null,
|
||
omsOptions: {
|
||
markersWontMove: true,
|
||
markersWontHide: true,
|
||
basicFormatEvents: true,
|
||
nearbyDistance: 50,
|
||
circleSpiralSwitchover: Infinity,
|
||
circleFootSeparation: 50,
|
||
circleStartAngle: 3.14 / 6,
|
||
},
|
||
allMarkers: [],
|
||
markers: [
|
||
],
|
||
icons: {
|
||
icon: null,
|
||
iconClick: null,
|
||
iconMobile: null,
|
||
iconMobileClick: null,
|
||
siteIcon: null,
|
||
siteIconMobile: null
|
||
},
|
||
// Définition de la zone cliquable des icones
|
||
shape: {
|
||
coords: [0, 0, 0, 34, 34, 34, 34, 0],
|
||
type: 'poly'
|
||
},
|
||
siteMarkers: [
|
||
{
|
||
title: 'LDC Unité St Laurent',
|
||
subtitle: 'Pôle Volaille - LDC Sablé',
|
||
latitude: 47.827400616,
|
||
longitude: -0.310519238983
|
||
},
|
||
{
|
||
title: 'LDC Bourgogne',
|
||
subtitle: 'Pôle volaille - Pôle Sud-Est',
|
||
latitude: 46.6359368304,
|
||
longitude: 5.2114451804
|
||
},
|
||
{
|
||
title: 'Bazas',
|
||
subtitle: 'Pôle Volaille - LDC Sablé',
|
||
latitude: 44.432046,
|
||
longitude: -0.212601
|
||
},
|
||
]
|
||
}
|
||
},
|
||
computed: {
|
||
isMobile() {
|
||
return !window.matchMedia("(min-width: 769px)").matches
|
||
},
|
||
icon() {
|
||
return this.isOCB ?
|
||
this.asset('assets/images/gmap/icon-oui.png') :
|
||
this.asset('assets/images/gmap/icon-map.png')
|
||
},
|
||
iconClick() {
|
||
return this.isOCB ?
|
||
this.asset('assets/images/gmap/icon-oui-on.png') :
|
||
this.asset('assets/images/gmap/icon-map-on.png')
|
||
},
|
||
iconMobile() {
|
||
return this.isOCB ?
|
||
this.asset('assets/images/gmap/icon-oui-mobile.png') :
|
||
this.asset('assets/images/gmap/icon-map-mobile.png')
|
||
},
|
||
iconMobileClick() {
|
||
return this.isOCB ?
|
||
this.asset('assets/images/ocb/icon-oui-on-mobile.png') :
|
||
this.asset('assets/images/gmap/icon-map-on-mobile.png')
|
||
},
|
||
siteIcon() {
|
||
return this.asset('assets/images/ocb/site-oui.png')
|
||
},
|
||
siteIconMobile() {
|
||
return this.asset('assets/images/ocb/site-oui-mobile.png')
|
||
}
|
||
},
|
||
methods: {
|
||
closeBlockEleveur() {
|
||
this.$refs.blocEleveur.classList.add('display-none')
|
||
},
|
||
setMapOptions() {
|
||
// On resize window Refresh map
|
||
window.onresize = this.setMapOptions
|
||
|
||
if (this.isMobile) {
|
||
this.mapOptions.center = new google.maps.LatLng(48.121, 0.675392);
|
||
this.mapOptions.zoom = 6;
|
||
} else {
|
||
this.mapOptions.center = new google.maps.LatLng(49.132846, -3);
|
||
this.mapOptions.zoom = 5;
|
||
}
|
||
if (this.map) {
|
||
google.maps.event.trigger(this.map, "resize");
|
||
}
|
||
},
|
||
// Fonction pour ajouter un listener a chaque marqueur
|
||
addNewListener(mark, title, subtitle, content, portrait, link = null) {
|
||
let self = this
|
||
mark.addListener('spider_click', function () {
|
||
self.$refs.blocEleveur.classList.remove('display-none')
|
||
self.$refs.clickOn.classList.add('display-none')
|
||
self.reInitializeMarkerIcons()
|
||
self.$refs.title.innerText = title
|
||
self.$refs.subtitle.innerText = subtitle
|
||
if (content) {
|
||
self.$refs.content.innerText = content
|
||
} else {
|
||
self.$refs.content.innerText = '';
|
||
}
|
||
self.$refs.image.src = portrait
|
||
if (self.$refs.link) {
|
||
if (link) {
|
||
self.$refs.link.href = link
|
||
self.$refs.link.classList.remove('display-none')
|
||
} else {
|
||
self.$refs.link.classList.add('display-none')
|
||
}
|
||
}
|
||
mark.setIcon(self.IsMobile ? self.icons.iconMobileClick : self.icons.iconClick)
|
||
});
|
||
},
|
||
//Fonction remettant les markers rouge
|
||
reInitializeMarkerIcons() {
|
||
for (let marker of this.allMarkers) {
|
||
marker.setIcon(this.isMobile ? this.icons.iconMobile : this.icons.icon)
|
||
}
|
||
},
|
||
setMarkerWithTimeOut(mark, time) {
|
||
setTimeout(() => {
|
||
this.oms.addMarker(mark)
|
||
}, time)
|
||
},
|
||
setIcons() {
|
||
// Definition des icones personnalisées
|
||
this.icons.icon = {
|
||
url: this.icon,
|
||
size: new google.maps.Size(50, 50),
|
||
origin: new google.maps.Point(0, 0),
|
||
anchor: new google.maps.Point(17, 47),
|
||
};
|
||
this.icons.iconClick = {
|
||
url: this.iconClick,
|
||
size: new google.maps.Size(50, 50),
|
||
origin: new google.maps.Point(0, 0),
|
||
anchor: new google.maps.Point(17, 47)
|
||
};
|
||
this.icons.iconMobile = {
|
||
url: this.iconMobile,
|
||
size: new google.maps.Size(35, 35),
|
||
origin: new google.maps.Point(0, 0),
|
||
anchor: new google.maps.Point(12, 32),
|
||
};
|
||
this.icons.iconMobileClick = {
|
||
url: this.iconMobileClick,
|
||
size: new google.maps.Size(35, 35),
|
||
origin: new google.maps.Point(0, 0),
|
||
anchor: new google.maps.Point(12, 32)
|
||
};
|
||
this.icons.siteIcon = {
|
||
url: this.siteIcon,
|
||
size: new google.maps.Size(34, 48),
|
||
origin: new google.maps.Point(0, 0),
|
||
anchor: new google.maps.Point(17, 47)
|
||
};
|
||
this.icons.siteIconMobile = {
|
||
url: this.siteIconMobile,
|
||
size: new google.maps.Size(25, 35),
|
||
origin: new google.maps.Point(0, 0),
|
||
anchor: new google.maps.Point(17, 47)
|
||
};
|
||
},
|
||
hideGB() {
|
||
// Creation d'un polygone pour cacher la Grande Bretagne
|
||
let gbCoords = [
|
||
new google.maps.LatLng(50.858, 1.472),
|
||
new google.maps.LatLng(49.302, -6.251),
|
||
new google.maps.LatLng(52.447, -12.447),
|
||
new google.maps.LatLng(59.794, -8.690),
|
||
new google.maps.LatLng(59.483, -0.516),
|
||
new google.maps.LatLng(52.541, 3.416)
|
||
];
|
||
let cacheGB = new google.maps.Polygon({
|
||
paths: gbCoords,
|
||
strokeColor: '#92c0d3',
|
||
strokeOpacity: 1,
|
||
strokeWeight: 2,
|
||
fillColor: '#92c0d3',
|
||
fillOpacity: 1
|
||
});
|
||
|
||
cacheGB.setMap(this.map)
|
||
},
|
||
createMap() {
|
||
let self = this
|
||
this.map = new google.maps.Map(this.$refs.map, this.mapOptions)
|
||
this.oms = new OverlappingMarkerSpiderfier(this.map, this.omsOptions)
|
||
// test remove resize event
|
||
// google.maps.event.addDomListener(window, 'resize', function () {
|
||
// self.map.setCenter(self.mapOptions.center);
|
||
// self.map.setZoom(self.mapOptions.zoom);
|
||
// })
|
||
},
|
||
populateWithMarkers() {
|
||
//Boucle créant les marqueurs et les listeners pour chaque entree du tableau markers
|
||
for (let marker of this.markers) {
|
||
let mark = new google.maps.Marker({
|
||
position: new google.maps.LatLng(marker.latitude, marker.longitude),
|
||
icon: this.isMobile ? this.icons.iconMobile : this.icons.icon,
|
||
shape: this.shape,
|
||
animation: google.maps.Animation.DROP,
|
||
title: ''
|
||
});
|
||
this.addNewListener(
|
||
mark,
|
||
marker.firstname ?
|
||
(marker.firstname + (marker.departaimant ? ', ' + marker.departaimant : '')) : marker.title,
|
||
marker.ocbType ? (marker.ocbType + ' à ' + marker.place) : marker.subtitle,
|
||
marker.testimony ? marker.testimony : '',
|
||
marker.picture,
|
||
this.isOCB ? this.route('ocb.breeders')+'/'+marker.slug : null
|
||
);
|
||
this.allMarkers.push(mark);
|
||
}
|
||
|
||
if(this.isOCB) {
|
||
this.addSiteMarkers()
|
||
}
|
||
|
||
let i = 0;
|
||
for (let marker of this.allMarkers) {
|
||
this.setMarkerWithTimeOut(marker, i++ * 75);
|
||
}
|
||
},
|
||
addSiteMarkers() {
|
||
for(let siteMarker of this.siteMarkers) {
|
||
let mark = new google.maps.Marker({
|
||
position: new google.maps.LatLng(siteMarker.latitude, siteMarker.longitude),
|
||
icon: this.isMobile ? this.icons.siteIconMobile : this.icons.siteIcon,
|
||
animation: google.maps.Animation.DROP,
|
||
title: '',
|
||
type: "site",
|
||
});
|
||
this.addNewListener(mark, siteMarker.title, siteMarker.subtitle);
|
||
this.allMarkers.push(mark);
|
||
}
|
||
},
|
||
getBreederFromApi() {
|
||
let self = this
|
||
axios.get(this.route('map.breeders') + '?isocb=' + (self.isOCB ? '1' : '0') + '&ocbtype=' + self.ocbType.value )
|
||
.then(function (response) {
|
||
self.markers = response.data.data
|
||
setTimeout(() => {
|
||
self.populateWithMarkers()
|
||
}, 1500)
|
||
}).catch(function (error) {
|
||
console.error(error)
|
||
});
|
||
},
|
||
initMarkers() {
|
||
this.hasInitMarkers = true
|
||
if (this.hasInitMarkers && this.hasInitMap) {
|
||
this.init()
|
||
}
|
||
},
|
||
initMap() {
|
||
this.hasInitMap = true
|
||
if (this.hasInitMarkers && this.hasInitMap) {
|
||
this.init()
|
||
}
|
||
},
|
||
init() {
|
||
this.setMapOptions()
|
||
this.setIcons()
|
||
this.createMap()
|
||
this.hideGB()
|
||
this.getBreederFromApi()
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
@import '../../../sass/_variables.scss';
|
||
.portraits-eleveur {
|
||
position: relative;
|
||
width: 100%;
|
||
min-height: 650px;
|
||
@include max-width($tablet) {
|
||
min-height: 800px;
|
||
}
|
||
#map {
|
||
position: absolute;
|
||
padding: 0;
|
||
top: 0;
|
||
left: 0;
|
||
width: 100%;
|
||
height: 100%;
|
||
z-index: 1;
|
||
}
|
||
.portraits {
|
||
max-width: 1200px;
|
||
margin-left: auto;
|
||
margin-right: auto;
|
||
.txtLegende {
|
||
user-select: none;
|
||
pointer-events: none;
|
||
text-shadow: 0 0 11px #000;
|
||
position: relative;
|
||
z-index: 3;
|
||
width: 32rem;
|
||
padding: 1rem;
|
||
h3 {
|
||
font-size: 4em;
|
||
color: #fff;
|
||
|
||
img {
|
||
margin-left: 5px;
|
||
width: 68px;
|
||
height: auto;
|
||
vertical-align: middle;
|
||
}
|
||
}
|
||
p {
|
||
color: #fff;
|
||
font-size: 1.7em;
|
||
margin-top: 10px;
|
||
|
||
img {
|
||
vertical-align: middle;
|
||
margin: 0 2px;
|
||
}
|
||
}
|
||
h5 {
|
||
color: #fff;
|
||
position: relative;
|
||
padding-left: 52px;
|
||
line-height: 0.8em;
|
||
margin-top: 20px;
|
||
font-size: 3em;
|
||
&::before {
|
||
position: absolute;
|
||
font-family: "icomoon";
|
||
font-size: 1.3em;
|
||
top: 10px;
|
||
left: 2px;
|
||
content: "\e93c";
|
||
color: #fff;
|
||
}
|
||
}
|
||
@include max-width($tablet) {
|
||
padding: 30px;
|
||
padding-bottom: 0;
|
||
width: 60%;
|
||
h3 {
|
||
font-size: 3.4em;
|
||
}
|
||
p {
|
||
font-size: 1.5em;
|
||
}
|
||
h5 {
|
||
padding: 0;
|
||
width: 80%;
|
||
font-size: 2.5em;
|
||
&::before {
|
||
content: "";
|
||
}
|
||
}
|
||
}
|
||
@include max-width($mobile) {
|
||
padding: 40px 10px;
|
||
width: 100%;
|
||
top: 0;
|
||
h3 {
|
||
font-size: 2.8em;
|
||
}
|
||
p {
|
||
font-size: 1.2em;
|
||
}
|
||
h5 {
|
||
padding: 0;
|
||
width: 80%;
|
||
font-size: 2.2em;
|
||
&::before {
|
||
content: "";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
.blocEleveur {
|
||
max-width: 1200px;
|
||
margin-left: auto;
|
||
margin-right: auto;
|
||
.infoEleveur {
|
||
position: relative;
|
||
margin-left: 1rem;
|
||
background-color: #fff;
|
||
min-width: 22rem;
|
||
width: 25vw;
|
||
padding: 2rem;
|
||
box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.3);
|
||
z-index: 3;
|
||
border-bottom: 5px solid #f79e15;
|
||
&.ocb {
|
||
border-bottom: 5px solid #afcb03 !important;
|
||
a {
|
||
background-color: #afcb03 !important;
|
||
}
|
||
}
|
||
.info-close-btn {
|
||
display: block;
|
||
position: absolute;
|
||
right: 1rem;
|
||
top: 1rem;
|
||
font-size: 3em;
|
||
&:hover {
|
||
cursor: pointer;
|
||
}
|
||
}
|
||
img {
|
||
float: left;
|
||
width: 125px;
|
||
height: auto;
|
||
margin-right: 20px;
|
||
}
|
||
.txtEleveur {
|
||
h6 {
|
||
margin-bottom: 5px;
|
||
}
|
||
}
|
||
a {
|
||
margin: 0 auto;
|
||
margin-top: 15px;
|
||
width: 150px;
|
||
background-color: #f79e15;
|
||
color: #fff;
|
||
padding: 5px 20px 4px 20px;
|
||
font-size: 1.5em;
|
||
font-family: "Catamaran-Bold";
|
||
text-transform: uppercase;
|
||
border-radius: 16px;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
}
|
||
@include max-width($tablet) {
|
||
margin-left: 0;
|
||
margin-top: 30rem;
|
||
width: 87vw;
|
||
}
|
||
@include max-width($mobile) {
|
||
width: 100%;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style>
|