map for events

This commit is contained in:
Benjamin Takats
2022-12-15 19:47:21 +01:00
parent ca5b74d072
commit b9cb4f8999
5 changed files with 28 additions and 22 deletions

View File

@@ -25,26 +25,29 @@ class BitcoinEventTable extends Component
{ {
return view('livewire.bitcoin-event.bitcoin-event-table', [ return view('livewire.bitcoin-event.bitcoin-event-table', [
'markers' => BitcoinEvent::query() 'markers' => BitcoinEvent::query()
->with([ ->with([
'venue.city.country', 'venue.city.country',
]) ])
->whereHas('venue.city.country', ->where(fn($query) => $query
fn($query) => $query->where('countries.code', $this->country->code)) ->whereHas('venue.city.country',
->get() fn($query) => $query->where('code', $this->country->code))
->map(fn($event) => [ ->orWhere('show_worldwide', true)
'id' => $event->id, )
'name' => $event->name, ->get()
'coords' => [$event->venue->city->latitude, $event->venue->city->longitude], ->map(fn($event) => [
]), 'id' => $event->id,
'events' => BitcoinEvent::query() 'name' => $event->name,
->get() 'coords' => [$event->venue->city->latitude, $event->venue->city->longitude],
->map(fn($event) => [ ]),
'id' => $event->id, 'events' => BitcoinEvent::query()
'startDate' => $event->from, ->get()
'endDate' => $event->to, ->map(fn($event) => [
'location' => $event->title, 'id' => $event->id,
'description' => $event->description, 'startDate' => $event->from,
]), 'endDate' => $event->to,
'location' => $event->title,
'description' => $event->description,
]),
]); ]);
} }

File diff suppressed because one or more lines are too long

View File

@@ -15,6 +15,7 @@
media="screen"/> media="screen"/>
<script src="https://unpkg.com/jquery"></script> <script src="https://unpkg.com/jquery"></script>
<script src="{{ asset('vendor/jvector/jquery-jvectormap-2.0.5.min.js') }}"></script> <script src="{{ asset('vendor/jvector/jquery-jvectormap-2.0.5.min.js') }}"></script>
<script src="{{ asset('vendor/jvector/maps/europe-merc.js') }}"></script>
<script src="{{ asset('vendor/jvector/maps/de.js') }}"></script> <script src="{{ asset('vendor/jvector/maps/de.js') }}"></script>
<script src="{{ asset('vendor/jvector/maps/at.js') }}"></script> <script src="{{ asset('vendor/jvector/maps/at.js') }}"></script>
<script src="{{ asset('vendor/jvector/maps/ch.js') }}"></script> <script src="{{ asset('vendor/jvector/maps/ch.js') }}"></script>

View File

@@ -15,6 +15,7 @@
media="screen"/> media="screen"/>
<script src="https://unpkg.com/jquery"></script> <script src="https://unpkg.com/jquery"></script>
<script src="{{ asset('vendor/jvector/jquery-jvectormap-2.0.5.min.js') }}"></script> <script src="{{ asset('vendor/jvector/jquery-jvectormap-2.0.5.min.js') }}"></script>
<script src="{{ asset('vendor/jvector/maps/europe-merc.js') }}"></script>
<script src="{{ asset('vendor/jvector/maps/de.js') }}"></script> <script src="{{ asset('vendor/jvector/maps/de.js') }}"></script>
<script src="{{ asset('vendor/jvector/maps/at.js') }}"></script> <script src="{{ asset('vendor/jvector/maps/at.js') }}"></script>
<script src="{{ asset('vendor/jvector/maps/ch.js') }}"></script> <script src="{{ asset('vendor/jvector/maps/ch.js') }}"></script>

View File

@@ -86,7 +86,7 @@
$('#map').vectorMap({ $('#map').vectorMap({
zoomButtons : false, zoomButtons : false,
zoomOnScroll: true, zoomOnScroll: true,
map: '{{ $country->code }}_merc', map: 'europe_merc',
backgroundColor: 'transparent', backgroundColor: 'transparent',
markers: markers.map(function(h){ return {name: h.name, latLng: h.coords} }), markers: markers.map(function(h){ return {name: h.name, latLng: h.coords} }),
onMarkerClick: function(event, index) { onMarkerClick: function(event, index) {
@@ -110,7 +110,7 @@
} }
}" }"
> >
<div id="map" style="width: 100%; height: 400px"></div> <div id="map" style="width: 100%; height: 800px"></div>
</div> </div>
</div> </div>
</div> </div>