<commit_before><template>
  <div>
    <!--div v-for="(marker, idx) in markers">
      lat-lng: {{marker.latLng}}
      icon {{marker.icon}}
    </div>-->
    <v-map :zoom="zoom" :bounds="bounds" :center="center">
      <v-tile-layer :url="url" :attribution="attribution"></v-tile-layer>
      <v-marker v-for="marker in storeMarkers" :key="marker.id" :lat-lng="marker.latLng" :icon="marker.icon">
        <v-popup :content="marker.popupcontent"></v-popup>
      </v-marker>
      <v-marker v-for="marker in userMarkers" :key="marker.id" :lat-lng="marker.latLng" :icon="marker.icon">
        <v-popup :content="marker.popupcontent"></v-popup>
      </v-marker>
    </v-map>
  </div>
</template>

<script>
import {
  Map as VMap,
  TileLayer as VTileLayer,
  Marker as VMarker,
  Popup as VPopup,
} from 'vue2-leaflet'

import L from 'leaflet'
import 'leaflet.awesome-markers/dist/leaflet.awesome-markers.js'

// fix default marker icon. Should hopefully get fixed in Leaflet 1.3
// https://github.com/Leaflet/Leaflet/issues/4968
delete L.Icon.Default.prototype._getIconUrl
L.Icon.Default.mergeOptions({
  iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
  iconUrl: require('leaflet/dist/images/marker-icon.png'),
  shadowUrl: require('leaflet/dist/images/marker-shadow.png'),
})

export default {
  components: {
    VMap, VTileLayer, VMarker, VPopup,
  },
  data () {
    return {
      zoom: 13,
      center: L.latLng(49.9105778076202, 8.65834236145019),
      url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
      attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
    }
  },
  props: {
    users: { required: false, default: () => [] },
    stores: { required: false, default: () => [] },
    showUsers: { required: false, default: true },
    showStores: { required: false, default: true },
  },
  computed: {
    storeMarkers () {
      if (!this.showStores) return []
      return this.stores.filter(hasLocation).map(store => {
        return {
          latLng: L.latLng(store.latitude, store.longitude),
          id: 'store_' + store.id,
          icon: L.AwesomeMarkers.icon({
            icon: 'shopping-cart',
            markerColor: 'blue',
            prefix: 'fa',
          }),
          popupcontent: `<a href="/#/group/${store.group}/store/${store.id}">${store.name}</a>`,
        }
      })
    },
    userMarkers () {
      if (!this.showUsers) return []
      return this.users.filter(hasLocation).map(user => {
        return {
          latLng: L.latLng(user.latitude, user.longitude),
          id: 'user_' + user.id,
          icon: L.AwesomeMarkers.icon({
            icon: 'user',
            markerColor: 'green',
            prefix: 'fa',
          }),
          popupcontent: `<a href="/#/user/${user.id}">${user.displayName}</a>`,
        }
      })
    },
    bounds () {
      let markers = [...this.storeMarkers]
      if (markers.length === 0) {
        markers = [...this.storeMarkers, ...this.userMarkers]
      }
      if (markers.length > 0) {
        return L.latLngBounds(markers.map(m => m.latLng)).pad(0.2)
      }
      else {
        return L.latLngBounds()
      }
    },
  },
}

function hasLocation (item) {
  return item.latitude && item.longitude
}
</script>

<style>
@import "~leaflet/dist/leaflet.css";
@import "~leaflet.awesome-markers/dist/leaflet.awesome-markers.css";

</style>
<commit_msg>Simplify GroupMap<commit_after><template>
  <div>
    <v-map :zoom="zoom" :bounds="bounds" :center="center">
      <v-tile-layer :url="url" :attribution="attribution"></v-tile-layer>
      <v-marker v-for="marker in markers" :key="marker.id" :lat-lng="marker.latLng" :icon="marker.icon">
        <v-popup :content="marker.popupcontent"></v-popup>
      </v-marker>
    </v-map>
  </div>
</template>

<script>
import {
  Map as VMap,
  TileLayer as VTileLayer,
  Marker as VMarker,
  Popup as VPopup,
} from 'vue2-leaflet'

import L from 'leaflet'
import 'leaflet.awesome-markers/dist/leaflet.awesome-markers.js'

// fix default marker icon. Should hopefully get fixed in Leaflet 1.3
// https://github.com/Leaflet/Leaflet/issues/4968
delete L.Icon.Default.prototype._getIconUrl
L.Icon.Default.mergeOptions({
  iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
  iconUrl: require('leaflet/dist/images/marker-icon.png'),
  shadowUrl: require('leaflet/dist/images/marker-shadow.png'),
})

export default {
  components: {
    VMap, VTileLayer, VMarker, VPopup,
  },
  data () {
    return {
      zoom: 13,
      center: L.latLng(49.9105778076202, 8.65834236145019),
      url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
      attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
    }
  },
  props: {
    users: { required: false, default: () => [] },
    stores: { required: false, default: () => [] },
    showUsers: { required: false, default: true },
    showStores: { required: false, default: true },
  },
  computed: {
    markers () {
      let items = []
      if (this.showStores) {
        items.push(...this.stores.filter(hasLocation).map(store => {
          return {
            latLng: L.latLng(store.latitude, store.longitude),
            id: 'store_' + store.id,
            icon: L.AwesomeMarkers.icon({
              icon: 'shopping-cart',
              markerColor: 'blue',
              prefix: 'fa',
            }),
            popupcontent: `<a href="/#/group/${store.group}/store/${store.id}">${store.name}</a>`,
          }
        }))
      }
      if (this.showUsers) {
        items.push(...this.users.filter(hasLocation).map(user => {
          return {
            latLng: L.latLng(user.latitude, user.longitude),
            id: 'user_' + user.id,
            icon: L.AwesomeMarkers.icon({
              icon: 'user',
              markerColor: 'green',
              prefix: 'fa',
            }),
            popupcontent: `<a href="/#/user/${user.id}">${user.displayName}</a>`,
          }
        }))
      }
      return items
    },
    bounds () {
      if (this.markers.length > 0) {
        return L.latLngBounds(this.markers.map(m => m.latLng)).pad(0.2)
      }
      else {
        return L.latLngBounds()
      }
    },
  },
}

function hasLocation (item) {
  return item.latitude && item.longitude
}
</script>

<style>
@import "~leaflet/dist/leaflet.css";
@import "~leaflet.awesome-markers/dist/leaflet.awesome-markers.css";

</style>

{'fraction_non_alphanumeric': 0.17790175112350845, 'fraction_numerical': 0.013482101348210134, 'mean_word_length': 2.503800217155266, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 66, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3807383', 'n_tokens_mistral': 2305, 'n_tokens_neox': 2234, 'n_words': 383}