From b40a55b0b6b28561c555c40f76bcb3e706dc8358 Mon Sep 17 00:00:00 2001 From: Ben Benesh Date: Mon, 6 Apr 2015 10:28:03 -0500 Subject: [PATCH 1/3] Adds parameter for GMaps API key. --- www/app/config/parameters.yml.dist | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/app/config/parameters.yml.dist b/www/app/config/parameters.yml.dist index 85159f7..935ec41 100644 --- a/www/app/config/parameters.yml.dist +++ b/www/app/config/parameters.yml.dist @@ -21,3 +21,6 @@ parameters: # Api key for aprs.fi. Sign up for an account there to get a key. aprs_fi_api_key: ReplaceThisWIthYourKey + + # Api key for Google Maps + google_maps_api_key: ReplaceThisWithYourKey From 1e1f76b5af1c56aadb57fafb9c82fe731162d189 Mon Sep 17 00:00:00 2001 From: Ben Benesh Date: Mon, 6 Apr 2015 11:52:13 -0500 Subject: [PATCH 2/3] adds map display to individual station pages --- www/app/config/config.yml | 2 + .../Controller/DefaultController.php | 1 - .../Resources/views/layout.html.twig | 5 ++ .../DataFixtures/ORM/LoadStationData.php | 4 ++ .../Entity/Station.php | 42 ++++++++++++++++ .../Form/StationType.php | 2 + .../Resources/config/doctrine/Station.orm.yml | 6 +++ .../Resources/views/Station/show.html.twig | 49 +++++++++++++++++++ 8 files changed, 110 insertions(+), 1 deletion(-) diff --git a/www/app/config/config.yml b/www/app/config/config.yml index 6a0fc01..b3dfff7 100644 --- a/www/app/config/config.yml +++ b/www/app/config/config.yml @@ -29,6 +29,8 @@ framework: twig: debug: "%kernel.debug%" strict_variables: "%kernel.debug%" + globals: + map_api_key: %google_maps_api_key% # Assetic Configuration assetic: diff --git a/www/src/Ecwec/Bundle/CoreBundle/Controller/DefaultController.php b/www/src/Ecwec/Bundle/CoreBundle/Controller/DefaultController.php index 206d82c..8797825 100644 --- a/www/src/Ecwec/Bundle/CoreBundle/Controller/DefaultController.php +++ b/www/src/Ecwec/Bundle/CoreBundle/Controller/DefaultController.php @@ -46,7 +46,6 @@ public function indexAction() 'name' => $station['name'], 'temp' => $temp ]; - ///var_dump($station['temp']); } return $this->render('CoreBundle::index.html.twig', array('stations' => $stations)); diff --git a/www/src/Ecwec/Bundle/CoreBundle/Resources/views/layout.html.twig b/www/src/Ecwec/Bundle/CoreBundle/Resources/views/layout.html.twig index 9fe3e01..1df1a65 100644 --- a/www/src/Ecwec/Bundle/CoreBundle/Resources/views/layout.html.twig +++ b/www/src/Ecwec/Bundle/CoreBundle/Resources/views/layout.html.twig @@ -14,6 +14,9 @@ {% include 'BraincraftedBootstrapBundle::ie8-support.html.twig' %} + {% block topjs %} + {% endblock %} + @@ -44,5 +47,7 @@ +{% block bottomjs %} +{% endblock %} \ No newline at end of file diff --git a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/DataFixtures/ORM/LoadStationData.php b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/DataFixtures/ORM/LoadStationData.php index 1870e40..b24c7eb 100644 --- a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/DataFixtures/ORM/LoadStationData.php +++ b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/DataFixtures/ORM/LoadStationData.php @@ -18,12 +18,16 @@ public function load(ObjectManager $manager) $station->setObjectId('AJ4NR'); $station->setName('AJ4NR'); $station->setDescription('AJ4NR'); + $station->setLatitude(44.16200); + $station->setLongitude(-88.55917); $manager->persist($station); $station = new Station(); $station->setObjectId('EW3427'); $station->setName('EW3427'); $station->setDescription('EW3427'); + $station->setLatitude(44.03400); + $station->setLongitude(-88.75383); $manager->persist($station); $manager->flush(); diff --git a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Entity/Station.php b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Entity/Station.php index 74b3aa7..fdecfcd 100644 --- a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Entity/Station.php +++ b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Entity/Station.php @@ -29,6 +29,16 @@ class Station */ private $description; + /** + * @var number + */ + private $latitude; + + /** + * @var number + */ + private $longitude; + /** * Get id @@ -108,4 +118,36 @@ public function getDescription() { return $this->description; } + + /** + * @return float + */ + public function getLatitude() + { + return $this->latitude; + } + + /** + * @param float $latitude + */ + public function setLatitude($latitude) + { + $this->latitude = $latitude; + } + + /** + * @return float + */ + public function getLongitude() + { + return $this->longitude; + } + + /** + * @param float $longitude + */ + public function setLongitude($longitude) + { + $this->longitude = $longitude; + } } diff --git a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Form/StationType.php b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Form/StationType.php index cf05e8c..2460166 100644 --- a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Form/StationType.php +++ b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Form/StationType.php @@ -18,6 +18,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) ->add('objectId') ->add('name') ->add('description') + ->add('latitude') + ->add('longitude') ; } diff --git a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/config/doctrine/Station.orm.yml b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/config/doctrine/Station.orm.yml index 682cb43..fb2adfe 100644 --- a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/config/doctrine/Station.orm.yml +++ b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/config/doctrine/Station.orm.yml @@ -18,4 +18,10 @@ Ecwec\Bundle\WeatherDataProviderBundle\Entity\Station: length: 255 description: type: text + latitude: + type: float + length: 255 + longitude: + type: float + length: 255 lifecycleCallbacks: { } diff --git a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/show.html.twig b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/show.html.twig index e718b3b..f19b57b 100644 --- a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/show.html.twig +++ b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/show.html.twig @@ -1,5 +1,32 @@ {% extends 'CoreBundle::layout.html.twig' %} +{% block topjs %} + + + + +{% endblock %} + {% block title %}Station{% endblock %} {% block content -%} @@ -21,10 +48,32 @@ Description {{ entity.description }} + + Coordinates + {{ entity.latitude }}, {{ entity.longitude }} + +
+ Back to the list

{{ form(delete_form) }} {% endblock %} + +{% block bottomjs %} + +{% endblock %} From 4988c5621037ecc81e97d2f0cddabe1725a9665e Mon Sep 17 00:00:00 2001 From: Ben Benesh Date: Sun, 19 Jul 2015 17:17:32 -0500 Subject: [PATCH 3/3] Adds view and updates fixtures. --- .../Ecwec/Bundle/CoreBundle/Menu/Builder.php | 2 + .../Controller/StationController.php | 15 +++++ .../DataFixtures/ORM/LoadStationData.php | 28 +++++---- .../Resources/config/routing/station.yml | 4 ++ .../Resources/views/Station/map.html.twig | 58 +++++++++++++++++++ .../Resources/views/Station/show.html.twig | 2 +- 6 files changed, 98 insertions(+), 11 deletions(-) create mode 100644 www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/map.html.twig diff --git a/www/src/Ecwec/Bundle/CoreBundle/Menu/Builder.php b/www/src/Ecwec/Bundle/CoreBundle/Menu/Builder.php index b4f94cc..a874b4e 100644 --- a/www/src/Ecwec/Bundle/CoreBundle/Menu/Builder.php +++ b/www/src/Ecwec/Bundle/CoreBundle/Menu/Builder.php @@ -14,6 +14,8 @@ public function mainMenu(FactoryInterface $factory, array $options) $menu->addChild('Home', array('route' => 'core_homepage')); $menu->addChild('Stations', array('route' => 'station')); + $menu['Stations']->addChild('All', array('route' => 'station')); + $menu['Stations']->addChild('Map', array('route' => 'station_map')); // access services from the container! $em = $this->container->get('doctrine')->getManager(); diff --git a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Controller/StationController.php b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Controller/StationController.php index 2bbfd5a..6c7b935 100644 --- a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Controller/StationController.php +++ b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Controller/StationController.php @@ -29,6 +29,21 @@ public function indexAction() 'entities' => $entities, )); } + + /** + * List all Stations on a map. + */ + public function mapAction() + { + $em = $this->getDoctrine()->getManager(); + + $entities = $em->getRepository('WeatherDataProviderBundle:Station')->findAll(); + + return $this->render('WeatherDataProviderBundle:Station:map.html.twig', array( + 'entities' => $entities, + )); + } + /** * Creates a new Station entity. * diff --git a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/DataFixtures/ORM/LoadStationData.php b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/DataFixtures/ORM/LoadStationData.php index b24c7eb..e137aca 100644 --- a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/DataFixtures/ORM/LoadStationData.php +++ b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/DataFixtures/ORM/LoadStationData.php @@ -15,19 +15,27 @@ class LoadStationData implements FixtureInterface public function load(ObjectManager $manager) { $station = new Station(); - $station->setObjectId('AJ4NR'); - $station->setName('AJ4NR'); - $station->setDescription('AJ4NR'); - $station->setLatitude(44.16200); - $station->setLongitude(-88.55917); + $station->setObjectId('WIWIWXOMR'); + $station->setName('WIWIWXOMR'); + $station->setDescription('WIWIWXOMR'); + $station->setLatitude(44.045); + $station->setLongitude(-88.704); $manager->persist($station); $station = new Station(); - $station->setObjectId('EW3427'); - $station->setName('EW3427'); - $station->setDescription('EW3427'); - $station->setLatitude(44.03400); - $station->setLongitude(-88.75383); + $station->setObjectId('WIWIWXERK'); + $station->setName('WIWIWXERK'); + $station->setDescription('WIWIWXERK'); + $station->setLatitude(44.004); + $station->setLongitude(-88.842); + $manager->persist($station); + + $station = new Station(); + $station->setObjectId('WIWIWXWLF'); + $station->setName('WIWIWXWLF'); + $station->setDescription('WIWIWXWLF'); + $station->setLatitude(44.213); + $station->setLongitude(-88.846); $manager->persist($station); $manager->flush(); diff --git a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/config/routing/station.yml b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/config/routing/station.yml index 2455774..b734208 100644 --- a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/config/routing/station.yml +++ b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/config/routing/station.yml @@ -2,6 +2,10 @@ station: path: / defaults: { _controller: "WeatherDataProviderBundle:Station:index" } +station_map: + path: /map + defaults: { _controller: "WeatherDataProviderBundle:Station:map" } + station_show: path: /{id}/show defaults: { _controller: "WeatherDataProviderBundle:Station:show" } diff --git a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/map.html.twig b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/map.html.twig new file mode 100644 index 0000000..b1fcdb3 --- /dev/null +++ b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/map.html.twig @@ -0,0 +1,58 @@ +{% extends 'CoreBundle::layout.html.twig' %} +{% set firstStation = entities|first %} +{% block topjs %} + + + + +{% endblock %} + +{% block title %}Stations{% endblock %} +{% block content -%} + New +
+{% endblock %} + +{% block bottomjs %} + +{% endblock %} diff --git a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/show.html.twig b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/show.html.twig index f19b57b..02e56e4 100644 --- a/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/show.html.twig +++ b/www/src/Ecwec/Bundle/WeatherDataProviderBundle/Resources/views/Station/show.html.twig @@ -12,7 +12,7 @@ function initialize() { var mapOptions = { center: { lat: {{ entity.latitude }}, lng: {{entity.longitude }}}, - zoom: 8 + zoom: 14 }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);