- fixed quantità
- creazione mappa numero utenti per provincia !
This commit is contained in:
145
src/components/CMapUsers/CMapUsers.ts
Executable file
145
src/components/CMapUsers/CMapUsers.ts
Executable file
@@ -0,0 +1,145 @@
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { PropType, defineComponent, onMounted, ref, computed } from 'vue'
|
||||
|
||||
import 'leaflet/dist/leaflet.css'
|
||||
import * as L from 'leaflet'
|
||||
import 'leaflet.markercluster/dist/MarkerCluster.css';
|
||||
import 'leaflet.markercluster/dist/MarkerCluster.Default.css';
|
||||
import "leaflet.markercluster";
|
||||
|
||||
import { useUserStore } from '@src/store/UserStore'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMapUsers',
|
||||
setup(props, { emit }) {
|
||||
const $q = useQuasar()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const iconWidth = ref(25)
|
||||
const iconHeight = ref(40)
|
||||
const map = ref(<any>null)
|
||||
const zoom = ref(6)
|
||||
const arrprovince = ref(<any>[])
|
||||
|
||||
const initialMap = ref(<any>null);
|
||||
|
||||
const myIcon = L.icon({
|
||||
iconUrl: 'images/icon.png',
|
||||
iconSize: [30, 30],
|
||||
iconAnchor: [22, 35],
|
||||
popupAnchor: [-6, -36],
|
||||
shadowUrl: 'images/marker-shadow.png',
|
||||
shadowSize: [60, 30],
|
||||
shadowAnchor: [22, 35]
|
||||
});
|
||||
|
||||
|
||||
function mywidth() {
|
||||
return tools.getwidth($q) - 20
|
||||
}
|
||||
|
||||
function myheight() {
|
||||
return $q.screen.height - 50
|
||||
}
|
||||
|
||||
const iconUrl = computed(() => {
|
||||
return `https://placekitten.com/${iconWidth.value}/${iconHeight.value}`;
|
||||
})
|
||||
|
||||
const iconSize = computed(() => {
|
||||
return [iconWidth.value, iconHeight.value];
|
||||
})
|
||||
|
||||
function changeIcon() {
|
||||
iconWidth.value += 2;
|
||||
if (iconWidth.value > iconHeight.value) {
|
||||
iconWidth.value = Math.floor(iconHeight.value / 2);
|
||||
}
|
||||
}
|
||||
|
||||
function getColor(d: any) {
|
||||
return d > 1000 ? '#800026' :
|
||||
d > 500 ? '#BD0026' :
|
||||
d > 200 ? '#E31A1C' :
|
||||
d > 100 ? '#FC4E2A' :
|
||||
d > 50 ? '#FD8D3C' :
|
||||
d > 20 ? '#FEB24C' :
|
||||
d > 10 ? '#FED976' :
|
||||
'#FFEDA0';
|
||||
}
|
||||
|
||||
function style(feature: any) {
|
||||
return {
|
||||
fillColor: getColor(feature.properties.density),
|
||||
weight: 2,
|
||||
opacity: 1,
|
||||
color: 'white',
|
||||
dashArray: '3',
|
||||
fillOpacity: 0.7
|
||||
};
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// Ottengo la lista degli utenti con i lat e long
|
||||
arrprovince.value = await userStore.getProvincesForMap()
|
||||
|
||||
initialMap.value = L.map('map',
|
||||
{
|
||||
zoomControl: true, zoom: zoom.value, zoomAnimation: false,
|
||||
fadeAnimation: true, markerZoomAnimation: true,
|
||||
center: [42.71, 12.934],
|
||||
}
|
||||
);
|
||||
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 13,
|
||||
attribution: ''
|
||||
}).addTo(initialMap.value);
|
||||
|
||||
// @ts-ignore
|
||||
const markers = L.markerClusterGroup();
|
||||
|
||||
for (const provincia of arrprovince.value) {
|
||||
if (provincia.lat && provincia.long && provincia.userCount > 1) {
|
||||
// @ts-ignore
|
||||
let each_marker = new L.marker(
|
||||
[provincia.lat, provincia.long], { icon: myIcon })
|
||||
.bindPopup(`<strong> ${provincia.descr}:
|
||||
${provincia.userCount} utenti </strong>`);
|
||||
markers.addLayer(each_marker);
|
||||
}
|
||||
}
|
||||
|
||||
initialMap.value.addLayer(markers);
|
||||
|
||||
});
|
||||
|
||||
function log(str: string) {
|
||||
console.log(str)
|
||||
}
|
||||
|
||||
function getCoordinates(e: any) {
|
||||
// Ottieni la latitudine e la longitudine dal click
|
||||
const lat = e.latlng.lat
|
||||
const lng = e.latlng.lng
|
||||
|
||||
// Fai qualcosa con le coordinate, ad esempio stamparle in console
|
||||
console.log(`Latitudine: ${lat}, Longitudine: ${lng}`)
|
||||
}
|
||||
|
||||
return {
|
||||
mywidth,
|
||||
myheight,
|
||||
map,
|
||||
iconWidth,
|
||||
iconHeight,
|
||||
iconUrl,
|
||||
iconSize,
|
||||
changeIcon,
|
||||
zoom,
|
||||
log,
|
||||
getCoordinates,
|
||||
arrprovince,
|
||||
}
|
||||
}
|
||||
})
|
||||
44
src/components/CMapUsers/CMapUsers.vue
Executable file
44
src/components/CMapUsers/CMapUsers.vue
Executable file
@@ -0,0 +1,44 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="arrprovince" id="map" :style="`height:${myheight()}px; width:99%`">
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div :style="`height:${myheight()}px; width:99%`">
|
||||
<l-map
|
||||
v-model="zoom"
|
||||
v-model:zoom="zoom"
|
||||
:center="[42.71, 12.934]"
|
||||
@move="log('move')"
|
||||
@click="getCoordinates"
|
||||
>
|
||||
<l-tile-layer
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
></l-tile-layer>
|
||||
<l-control-layers />
|
||||
<span v-for="provincia in arrprovince" :key="provincia.nome">
|
||||
<l-marker-cluster :options="clusterOptions">
|
||||
<l-marker
|
||||
v-if="provincia.userCount > 0"
|
||||
:lat-lng="[provincia.lat, provincia.long]"
|
||||
>
|
||||
<l-popup
|
||||
>{{ provincia.descr }}:
|
||||
{{ provincia.userCount }} utenti</l-popup
|
||||
>
|
||||
</l-marker>
|
||||
</l-marker-cluster>
|
||||
</span>
|
||||
|
||||
</l-map>
|
||||
<button @click="changeIcon">New kitten icon</button>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" src="./CMapUsers.ts">
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './CMapUsers.scss';
|
||||
</style>
|
||||
1
src/components/CMapUsers/index.ts
Executable file
1
src/components/CMapUsers/index.ts
Executable file
@@ -0,0 +1 @@
|
||||
export {default as CMapUsers} from './CMapUsers.vue'
|
||||
@@ -16,6 +16,8 @@ import { CMyActivities } from '@/components/CMyActivities'
|
||||
import { CECommerce } from '@/components/CECommerce'
|
||||
import { CAITools } from '@/components/CAITools'
|
||||
import { CCatalogo } from '@/components/CCatalogo'
|
||||
// import { CMapMarker } from '@src/components/CMapMarker.off'
|
||||
import { CMapUsers } from '@/components/CMapUsers'
|
||||
import { COpenStreetMap } from '@src/components/COpenStreetMap'
|
||||
import { CCardCarousel } from '@src/components/CCardCarousel'
|
||||
import { CMyPage } from '@src/components/CMyPage'
|
||||
@@ -57,6 +59,7 @@ export default defineComponent({
|
||||
CMyProfileTutorial, CSendRISTo,
|
||||
CTitleBanner, CShareSocial, CCheckAppRunning, CRegistration,
|
||||
CVisuVideoPromoAndPDF, CECommerce, CCatalogo, CAITools,
|
||||
CMapUsers, //CMapMarker,
|
||||
},
|
||||
emits: ['selElemClick'],
|
||||
props: {
|
||||
|
||||
@@ -557,6 +557,17 @@
|
||||
<div v-if="editOn" class="elemEdit">PRODOTTI CATALOGO:</div>
|
||||
<CCatalogo> </CCatalogo>
|
||||
</div>
|
||||
<div v-else-if="myel.type === shared_consts.ELEMTYPE.MAPPA">
|
||||
<div v-if="editOn" class="elemEdit">MAPPA:</div>
|
||||
<CMapMarker :coord_center="{lat: 47.41322, long: -1.219482}"
|
||||
|
||||
></CMapMarker>
|
||||
</div>
|
||||
<div v-else-if="myel.type === shared_consts.ELEMTYPE.MAPPAUTENTI">
|
||||
<div v-if="editOn" class="elemEdit">MAPPA UTENTI:</div>
|
||||
<CMapUsers
|
||||
></CMapUsers>
|
||||
</div>
|
||||
<div v-else-if="myel.type === shared_consts.ELEMTYPE.TOOLSAI">
|
||||
<div v-if="editOn" class="elemEdit">STRUMENTI AI:</div>
|
||||
<CAITools></CAITools>
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { PropType, defineComponent, onMounted } from 'vue'
|
||||
|
||||
import 'leaflet/dist/leaflet.css'
|
||||
import { LMap, LTileLayer } from '@vue-leaflet/vue-leaflet'
|
||||
import { ICoordinates } from '@src/model'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'COpenStreetMap',
|
||||
components: {
|
||||
LMap,
|
||||
LTileLayer,
|
||||
},
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
coordinates: {
|
||||
type: Object as PropType<ICoordinates | null>,
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
coord_big: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
urlmap: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
imgmap: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
zoom: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 2,
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const $q = useQuasar()
|
||||
|
||||
function mywidth() {
|
||||
return tools.getwidth($q) - 20
|
||||
}
|
||||
|
||||
function myheight() {
|
||||
return 450
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
});
|
||||
|
||||
return {
|
||||
mywidth,
|
||||
myheight,
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,19 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<div style="height:600px; width:100%">
|
||||
<l-map ref="map" v-model:zoom="zoom" :center="[47.41322, -1.219482]">
|
||||
<l-tile-layer
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
layer-type="base"
|
||||
name="OpenStreetMap"
|
||||
></l-tile-layer>
|
||||
</l-map>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" src="./COSM.ts">
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './COSM.scss';
|
||||
</style>
|
||||
@@ -1 +0,0 @@
|
||||
export {default as COSM} from './COSM.vue'
|
||||
@@ -380,7 +380,7 @@ export default defineComponent({
|
||||
|
||||
function getpercqtaraggiunta(): number {
|
||||
if (myproduct.value)
|
||||
return tools.calcperc((myproduct.value.bookedGASQtyOrdered + myproduct.value.bookableAvailableQty!) * myproduct.value.productInfo.weight!, myproduct.value.qtyToReachForGas) / 100
|
||||
return tools.calcperc((myproduct.value.bookableGASBloccatiQty + myproduct.value.QuantitaPrenotateInAttesa!) * myproduct.value.productInfo.weight!, myproduct.value.qtyToReachForGas * myproduct.value.productInfo.weight!) / 100
|
||||
else
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@
|
||||
<q-item-label class="subtit_prod text-blue text-bold">
|
||||
<span v-if="getpercqtaraggiunta() >= 1">{{
|
||||
t('ecomm.offerta_gas_raggiunta', {
|
||||
qta: myproduct.qtyToReachForGas,
|
||||
qta: myproduct.qtyToReachForGas * myproduct.productInfo.weight,
|
||||
unit: tools.getUnitsMeasure(
|
||||
myproduct.productInfo.unit,
|
||||
true,
|
||||
@@ -515,7 +515,7 @@
|
||||
}}</span>
|
||||
<span v-else>{{
|
||||
t('ecomm.offerta_gas', {
|
||||
qta: myproduct.qtyToReachForGas,
|
||||
qta: myproduct.qtyToReachForGas * myproduct.productInfo.weight,
|
||||
unit: tools.getUnitsMeasure(
|
||||
myproduct.productInfo.unit,
|
||||
true,
|
||||
@@ -556,8 +556,8 @@
|
||||
<span class="prod_disp">
|
||||
{{
|
||||
t('ecomm.bookedGASQtyOrdered_str', {
|
||||
qta: (myproduct.bookedGASQtyOrdered + myproduct.bookableAvailableQty) * myproduct.productInfo.weight,
|
||||
qtatot: myproduct.qtyToReachForGas,
|
||||
qta: (myproduct.bookableGASBloccatiQty + myproduct.QuantitaPrenotateInAttesa) * myproduct.productInfo.weight,
|
||||
qtatot: myproduct.qtyToReachForGas * myproduct.productInfo.weight,
|
||||
})
|
||||
}}
|
||||
<q-linear-progress size="10px" :value="getpercqtaraggiunta()" />
|
||||
|
||||
Reference in New Issue
Block a user