Compare commits
2 commits
8ad0280b86
...
67a6c7d8dc
| Author | SHA1 | Date | |
|---|---|---|---|
| 67a6c7d8dc | |||
| 408d9f944c |
7 changed files with 46 additions and 15 deletions
14
assets/controllers/map_controller.js
Normal file
14
assets/controllers/map_controller.js
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
import L from 'leaflet';
|
||||||
|
import 'leaflet/dist/leaflet.min.css';
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
connect() {
|
||||||
|
const map = L.map(this.element).setView([51.0543, 3.7174], 13);
|
||||||
|
|
||||||
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
|
attribution: '© OpenStreetMap contributors',
|
||||||
|
maxZoom: 19,
|
||||||
|
}).addTo(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
body {
|
body {
|
||||||
background-color: skyblue;
|
background-color: skyblue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html, body { height: 100%; margin: 0; }
|
||||||
|
.map-container { height: 100vh; width: 100%; }
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,6 @@ return [
|
||||||
'@hotwired/stimulus' => ['version' => '3.2.2'],
|
'@hotwired/stimulus' => ['version' => '3.2.2'],
|
||||||
'@symfony/stimulus-bundle' => ['path' => './vendor/symfony/stimulus-bundle/assets/dist/loader.js'],
|
'@symfony/stimulus-bundle' => ['path' => './vendor/symfony/stimulus-bundle/assets/dist/loader.js'],
|
||||||
'@hotwired/turbo' => ['version' => '8.0.23'],
|
'@hotwired/turbo' => ['version' => '8.0.23'],
|
||||||
|
'leaflet' => ['version' => '1.9.4'],
|
||||||
|
'leaflet/dist/leaflet.min.css' => ['version' => '1.9.4', 'type' => 'css'],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
16
src/Controller/IndexController.php
Normal file
16
src/Controller/IndexController.php
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
|
class IndexController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/')]
|
||||||
|
public function index(): Response
|
||||||
|
{
|
||||||
|
return $this->render('index/page.html.twig');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -36,6 +36,8 @@ final class RestaurantFactory extends PersistentObjectFactory
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => self::faker()->company(),
|
'name' => self::faker()->company(),
|
||||||
|
'latitude' => self::faker()->latitude(),
|
||||||
|
'longitude' => self::faker()->longitude(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,6 @@
|
||||||
<html>
|
{% extends 'base.html.twig' %}
|
||||||
<head>
|
|
||||||
<title>Test</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Rater</h1>
|
|
||||||
{{ form(form) }}
|
|
||||||
|
|
||||||
<h2>Existing</h2>
|
{% block body %}
|
||||||
<ul>
|
<h1>Rater</h1>
|
||||||
{% for subject in subjects %}
|
<div {{ stimulus_controller('map') }} class="map-container"></div>
|
||||||
<li>{{ subject.name }}</li>
|
{% endblock %}
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,10 @@ class SubjectControllerTest extends WebTestCase
|
||||||
$data = json_decode($client->getResponse()->getContent(), true);
|
$data = json_decode($client->getResponse()->getContent(), true);
|
||||||
$this->assertResponseIsSuccessful();
|
$this->assertResponseIsSuccessful();
|
||||||
$this->assertCount(5, $data['payload']['subjects']);
|
$this->assertCount(5, $data['payload']['subjects']);
|
||||||
|
|
||||||
|
$subject = $data['payload']['subjects'][0];
|
||||||
|
$this->assertNotNull($subject['latitude']);
|
||||||
|
$this->assertNotNull($subject['longitude']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreate(): void
|
public function testCreate(): void
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue