From 991c8b3f1e6a85160d97b2863e80c8f9d21c1502 Mon Sep 17 00:00:00 2001 From: Bradley Cornford Date: Fri, 12 Jun 2015 11:18:53 +0100 Subject: [PATCH 01/40] Updated support for Laravel 5. --- README.md | 6 ++++-- composer.json | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9096cc8..50e5ae5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,9 @@ [![Build Status](https://travis-ci.org/bradcornford/Googlmapper.svg?branch=master)](https://travis-ci.org/bradcornford/Googlmapper) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bradcornford/Googlmapper/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/bradcornford/Googlmapper/?branch=master) -Think of Googlmapper as an easy way to integrate Google Maps with Laravel 4, providing a variety of helpers to speed up the utilisation of mapping. These include: +### For Laravel 4.x, check [version 1.0.1](https://github.com/bradcornford/Googlmapper/tree/v1.0.1) + +Think of Googlmapper as an easy way to integrate Google Maps with Laravel, providing a variety of helpers to speed up the utilisation of mapping. These include: - `Mapper::map` - `Mapper::stretview` @@ -22,7 +24,7 @@ Think of Googlmapper as an easy way to integrate Google Maps with Laravel 4, pro Begin by installing this package through Composer. Edit your project's `composer.json` file to require `cornford/googlmapper`. "require": { - "cornford/googlmapper": "1.*" + "cornford/googlmapper": "2.*" } Next, update Composer from the Terminal: diff --git a/composer.json b/composer.json index 07684b2..7a00fe9 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,7 @@ } ], "require": { - "php": ">=5.4.0", - "illuminate/support": "4.2.*" + "php": ">=5.4.0" }, "require-dev": { "phpspec/phpspec": "2.0.*@dev", From 9c3fefb4ceb985c991a53f6148bdd11db00f9556 Mon Sep 17 00:00:00 2001 From: Bradley Cornford Date: Fri, 12 Jun 2015 11:18:53 +0100 Subject: [PATCH 02/40] Updated support for Laravel 5. --- README.md | 6 ++- composer.json | 3 +- .../Googlmapper/MapperServiceProvider.php | 13 ++++-- src/views/circle.blade.php | 24 +++++------ src/views/map.blade.php | 32 +++++++-------- src/views/mapper.blade.php | 4 +- src/views/marker.blade.php | 40 +++++++++---------- src/views/overlay.blade.php | 12 +++--- src/views/polygon.blade.php | 22 +++++----- src/views/polyline.blade.php | 20 +++++----- src/views/rectangle.blade.php | 22 +++++----- src/views/streetview.blade.php | 20 +++++----- 12 files changed, 112 insertions(+), 106 deletions(-) diff --git a/README.md b/README.md index 9096cc8..50e5ae5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,9 @@ [![Build Status](https://travis-ci.org/bradcornford/Googlmapper.svg?branch=master)](https://travis-ci.org/bradcornford/Googlmapper) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bradcornford/Googlmapper/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/bradcornford/Googlmapper/?branch=master) -Think of Googlmapper as an easy way to integrate Google Maps with Laravel 4, providing a variety of helpers to speed up the utilisation of mapping. These include: +### For Laravel 4.x, check [version 1.0.1](https://github.com/bradcornford/Googlmapper/tree/v1.0.1) + +Think of Googlmapper as an easy way to integrate Google Maps with Laravel, providing a variety of helpers to speed up the utilisation of mapping. These include: - `Mapper::map` - `Mapper::stretview` @@ -22,7 +24,7 @@ Think of Googlmapper as an easy way to integrate Google Maps with Laravel 4, pro Begin by installing this package through Composer. Edit your project's `composer.json` file to require `cornford/googlmapper`. "require": { - "cornford/googlmapper": "1.*" + "cornford/googlmapper": "2.*" } Next, update Composer from the Terminal: diff --git a/composer.json b/composer.json index 07684b2..7a00fe9 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,7 @@ } ], "require": { - "php": ">=5.4.0", - "illuminate/support": "4.2.*" + "php": ">=5.4.0" }, "require-dev": { "phpspec/phpspec": "2.0.*@dev", diff --git a/src/Cornford/Googlmapper/MapperServiceProvider.php b/src/Cornford/Googlmapper/MapperServiceProvider.php index 479a4e7..22d4b78 100644 --- a/src/Cornford/Googlmapper/MapperServiceProvider.php +++ b/src/Cornford/Googlmapper/MapperServiceProvider.php @@ -19,7 +19,11 @@ class MapperServiceProvider extends ServiceProvider { */ public function boot() { - $this->package('cornford/googlmapper'); + $configPath = __DIR__ . '/../../config/config.php'; + $this->publishes([$configPath => config_path('config.php')], 'config'); + + $viewPath = __DIR__ . '/../../views'; + $this->loadViewsFrom($viewPath, 'googlmapper'); } /** @@ -29,13 +33,14 @@ public function boot() */ public function register() { + $configPath = __DIR__ . '/../../config/config.php'; + $this->mergeConfigFrom($configPath, 'googlmapper'); + $this->app['mapper'] = $this->app->share(function($app) { - $config = $app['config']->get('googlmapper::config'); - return new Mapper( $this->app->view, - $config + $app['config']->get('googlmapper') ); }); } diff --git a/src/views/circle.blade.php b/src/views/circle.blade.php index ce263b6..2425d13 100644 --- a/src/views/circle.blade.php +++ b/src/views/circle.blade.php @@ -1,18 +1,18 @@ -var circleCoordinates_{{ $id }} = ( +var circleCoordinates_{!! $id !!} = ( @foreach ($options['coordinates'] as $key => $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}) + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}) @endforeach ); -var circle_{{ $id }} = new google.maps.Circle({ - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - fillColor: '{{ $options['fillColor'] }}', - fillOpacity: {{ $options['fillOpacity'] }}, - center: circleCoordinates_{{ $id }}, - radius: {{ $options['radius'] }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var circle_{!! $id !!} = new google.maps.Circle({ + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + fillColor: '{!! $options['fillColor'] !!}', + fillOpacity: {!! $options['fillOpacity'] !!}, + center: circleCoordinates_{!! $id !!}, + radius: {!! $options['radius'] !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -circle_{{ $id }}.setMap({{ $options['map'] }}); \ No newline at end of file +circle_{!! $id !!}.setMap({!! $options['map'] !!}); \ No newline at end of file diff --git a/src/views/map.blade.php b/src/views/map.blade.php index 2bc0d0c..99a8052 100644 --- a/src/views/map.blade.php +++ b/src/views/map.blade.php @@ -1,56 +1,56 @@ -
+
\ No newline at end of file diff --git a/src/views/mapper.blade.php b/src/views/mapper.blade.php index d3c4c60..3fffcb9 100644 --- a/src/views/mapper.blade.php +++ b/src/views/mapper.blade.php @@ -1,8 +1,8 @@ - + @foreach ($items as $id => $item) - {{ $item->render($id, $view) }} + {!! $item->render($id, $view) !!} @endforeach diff --git a/src/views/marker.blade.php b/src/views/marker.blade.php index 47ebf5a..099f707 100644 --- a/src/views/marker.blade.php +++ b/src/views/marker.blade.php @@ -1,8 +1,8 @@ @if ($options['user'] && $options['place']) - var service = new google.maps.places.PlacesService({{ $options['map'] }}); + var service = new google.maps.places.PlacesService({!! $options['map'] !!}); var request = { - placeId: '{{ $options['place'] }}' + placeId: '{!! $options['place'] !!}' }; service.getDetails(request, function(placeResult, status) { @@ -13,41 +13,41 @@ @endif -var markerPosition_{{ $id }} = new google.maps.LatLng({{ $options['latitude'] }}, {{ $options['longitude'] }}); +var markerPosition_{!! $id !!} = new google.maps.LatLng({!! $options['latitude'] !!}, {!! $options['longitude'] !!}); -var marker_{{ $id }} = new google.maps.Marker({ - position: markerPosition_{{ $id }}, +var marker_{!! $id !!} = new google.maps.Marker({ + position: markerPosition_{!! $id !!}, @if ($options['user'] && $options['place']) place: { - placeId: '{{ $options['place'] }}', - location: { lat: {{ $options['latitude'] }}, lng: {{ $options['longitude'] }} } + placeId: '{!! $options['place'] !!}', + location: { lat: {!! $options['latitude'] !!}, lng: {!! $options['longitude'] !!} } }, attribution: { source: document.title, webUrl: document.URL }, @endif - title: '{{ $options['title'] }}', - animation: @if (empty($options['animation']) || $options['animation'] == 'NONE') '' @else google.maps.Animation.{{ $options['animation'] }} @endif, + title: '{!! $options['title'] !!}', + animation: @if (empty($options['animation']) || $options['animation'] == 'NONE') '' @else google.maps.Animation.{!! $options['animation'] !!} @endif, @if ($options['symbol']) icon: { - path: google.maps.SymbolPath.{{ $options['symbol'] }}, - scale: {{ $options['scale'] }} + path: google.maps.SymbolPath.{!! $options['symbol'] !!}, + scale: {!! $options['scale'] !!} } @else - icon: '{{ $options['icon'] }}' + icon: '{!! $options['icon'] !!}' @endif }); -bounds.extend(marker_{{ $id }}.position); +bounds.extend(marker_{!! $id !!}.position); -marker_{{ $id }}.setMap({{ $options['map'] }}); +marker_{!! $id !!}.setMap({!! $options['map'] !!}); @if ($options['user'] && $options['place']) - marker_{{ $id }}.addListener('click', function() { + marker_{!! $id !!}.addListener('click', function() { infowindow.setContent('' + placeResult.name + ''); - infowindow.open({{ $options['map'] }}, this); + infowindow.open({!! $options['map'] !!}, this); }); }); @@ -55,12 +55,12 @@ @if (!empty($options['content'])) - var infowindow_{{ $id }} = new google.maps.InfoWindow({ - content: '{{ $options['content'] }}' + var infowindow_{!! $id !!} = new google.maps.InfoWindow({ + content: '{!! $options['content'] !!}' }); - google.maps.event.addListener(marker_{{ $id }}, 'click', function() { - infowindow_{{ $id }}.open({{ $options['map'] }}, marker_{{ $id }}); + google.maps.event.addListener(marker_{!! $id !!}, 'click', function() { + infowindow_{!! $id !!}.open({!! $options['map'] !!}, marker_{!! $id !!}); }); @endif diff --git a/src/views/overlay.blade.php b/src/views/overlay.blade.php index d53bb66..da22bbc 100644 --- a/src/views/overlay.blade.php +++ b/src/views/overlay.blade.php @@ -1,12 +1,12 @@ -var overlayCoordinates_{{ $id }} = new google.maps.LatLngBounds( +var overlayCoordinates_{!! $id !!} = new google.maps.LatLngBounds( @foreach ($options['coordinates'] as $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}), + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}), @endforeach ); -overlay_{{ $id }} = new google.maps.GroundOverlay( - '{{ $options['image'] }}', - overlayCoordinates_{{ $id }} +overlay_{!! $id !!} = new google.maps.GroundOverlay( + '{!! $options['image'] !!}', + overlayCoordinates_{!! $id !!} ); -overlay_{{ $id }}.setMap({{ $options['map'] }}); +overlay_{!! $id !!}.setMap({!! $options['map'] !!}); diff --git a/src/views/polygon.blade.php b/src/views/polygon.blade.php index fa77fc3..6b24f94 100644 --- a/src/views/polygon.blade.php +++ b/src/views/polygon.blade.php @@ -1,17 +1,17 @@ -var polygonCoordinates_{{ $id }} = [ +var polygonCoordinates_{!! $id !!} = [ @foreach ($options['coordinates'] as $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}), + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}), @endforeach ]; -var polygon_{{ $id }} = new google.maps.Polygon({ - paths: polygonCoordinates_{{ $id }}, - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - fillColor: '{{ $options['fillColor'] }}', - fillOpacity: {{ $options['fillOpacity'] }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var polygon_{!! $id !!} = new google.maps.Polygon({ + paths: polygonCoordinates_{!! $id !!}, + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + fillColor: '{!! $options['fillColor'] !!}', + fillOpacity: {!! $options['fillOpacity'] !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -polygon_{{ $id }}.setMap({{ $options['map'] }}); +polygon_{!! $id !!}.setMap({!! $options['map'] !!}); diff --git a/src/views/polyline.blade.php b/src/views/polyline.blade.php index 4203904..e536213 100644 --- a/src/views/polyline.blade.php +++ b/src/views/polyline.blade.php @@ -1,16 +1,16 @@ -var polylineCoordinates_{{ $id }} = [ +var polylineCoordinates_{!! $id !!} = [ @foreach ($options['coordinates'] as $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}), + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}), @endforeach ]; -var polyline_{{ $id }} = new google.maps.Polyline({ - path: polylineCoordinates_{{ $id }}, - geodesic: {{ $options['strokeColor'] ? 'true' : 'false' }}, - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var polyline_{!! $id !!} = new google.maps.Polyline({ + path: polylineCoordinates_{!! $id !!}, + geodesic: {!! $options['strokeColor'] ? 'true' : 'false' !!}, + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -polyline_{{ $id }}.setMap({{ $options['map'] }}); \ No newline at end of file +polyline_{!! $id !!}.setMap({!! $options['map'] !!}); \ No newline at end of file diff --git a/src/views/rectangle.blade.php b/src/views/rectangle.blade.php index c8c2119..832ac80 100644 --- a/src/views/rectangle.blade.php +++ b/src/views/rectangle.blade.php @@ -1,17 +1,17 @@ -var rectangleCoordinates_{{ $id }} = new google.maps.LatLngBounds( +var rectangleCoordinates_{!! $id !!} = new google.maps.LatLngBounds( @foreach ($options['coordinates'] as $key => $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }})@if (count($options['coordinates']) - 1 > $key), @endif + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!})@if (count($options['coordinates']) - 1 > $key), @endif @endforeach ); -var rectangle_{{ $id }} = new google.maps.Rectangle({ - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - fillColor: '{{ $options['fillColor'] }}', - fillOpacity: {{ $options['fillOpacity'] }}, - bounds: rectangleCoordinates_{{ $id }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var rectangle_{!! $id !!} = new google.maps.Rectangle({ + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + fillColor: '{!! $options['fillColor'] !!}', + fillOpacity: {!! $options['fillOpacity'] !!}, + bounds: rectangleCoordinates_{!! $id !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -rectangle_{{ $id }}.setMap({{ $options['map'] }}); +rectangle_{!! $id !!}.setMap({!! $options['map'] !!}); diff --git a/src/views/streetview.blade.php b/src/views/streetview.blade.php index 55a4c62..94d3170 100644 --- a/src/views/streetview.blade.php +++ b/src/views/streetview.blade.php @@ -1,35 +1,35 @@ -
+
\ No newline at end of file From 4434fecdc9065438828766ab7ac21dd09ebe762d Mon Sep 17 00:00:00 2001 From: Bradley Cornford Date: Fri, 12 Jun 2015 11:18:53 +0100 Subject: [PATCH 03/40] Updated support for Laravel 5. --- README.md | 8 ++-- composer.json | 3 +- .../Googlmapper/MapperServiceProvider.php | 13 ++++-- src/views/circle.blade.php | 24 +++++------ src/views/map.blade.php | 32 +++++++-------- src/views/mapper.blade.php | 4 +- src/views/marker.blade.php | 40 +++++++++---------- src/views/overlay.blade.php | 12 +++--- src/views/polygon.blade.php | 22 +++++----- src/views/polyline.blade.php | 20 +++++----- src/views/rectangle.blade.php | 22 +++++----- src/views/streetview.blade.php | 20 +++++----- 12 files changed, 113 insertions(+), 107 deletions(-) diff --git a/README.md b/README.md index 9096cc8..68c42c2 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,9 @@ [![Build Status](https://travis-ci.org/bradcornford/Googlmapper.svg?branch=master)](https://travis-ci.org/bradcornford/Googlmapper) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bradcornford/Googlmapper/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/bradcornford/Googlmapper/?branch=master) -Think of Googlmapper as an easy way to integrate Google Maps with Laravel 4, providing a variety of helpers to speed up the utilisation of mapping. These include: +### For Laravel 4.x, check [version 1.0.1](https://github.com/bradcornford/Googlmapper/tree/v1.0.1) + +Think of Googlmapper as an easy way to integrate Google Maps with Laravel, providing a variety of helpers to speed up the utilisation of mapping. These include: - `Mapper::map` - `Mapper::stretview` @@ -22,7 +24,7 @@ Think of Googlmapper as an easy way to integrate Google Maps with Laravel 4, pro Begin by installing this package through Composer. Edit your project's `composer.json` file to require `cornford/googlmapper`. "require": { - "cornford/googlmapper": "1.*" + "cornford/googlmapper": "2.*" } Next, update Composer from the Terminal: @@ -39,7 +41,7 @@ The next step is to introduce the facade. Open `app/config/app.php`, and add a n Finally we need to introduce the configuration files into your application/ - php artisan config:publish cornford/googlmapper + php artisan vendor:publish --provider="Cornford\\Googlmapper\\MapperServiceProvider" That's it! You're all set to go. diff --git a/composer.json b/composer.json index 07684b2..7a00fe9 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,7 @@ } ], "require": { - "php": ">=5.4.0", - "illuminate/support": "4.2.*" + "php": ">=5.4.0" }, "require-dev": { "phpspec/phpspec": "2.0.*@dev", diff --git a/src/Cornford/Googlmapper/MapperServiceProvider.php b/src/Cornford/Googlmapper/MapperServiceProvider.php index 479a4e7..8ad5892 100644 --- a/src/Cornford/Googlmapper/MapperServiceProvider.php +++ b/src/Cornford/Googlmapper/MapperServiceProvider.php @@ -19,7 +19,11 @@ class MapperServiceProvider extends ServiceProvider { */ public function boot() { - $this->package('cornford/googlmapper'); + $configPath = __DIR__ . '/../../config/config.php'; + $this->publishes([$configPath => config_path('config.php')], 'googlmapper'); + + $viewPath = __DIR__ . '/../../views'; + $this->loadViewsFrom($viewPath, 'googlmapper'); } /** @@ -29,13 +33,14 @@ public function boot() */ public function register() { + $configPath = __DIR__ . '/../../config/config.php'; + $this->mergeConfigFrom($configPath, 'googlmapper'); + $this->app['mapper'] = $this->app->share(function($app) { - $config = $app['config']->get('googlmapper::config'); - return new Mapper( $this->app->view, - $config + $app['config']->get('googlmapper') ); }); } diff --git a/src/views/circle.blade.php b/src/views/circle.blade.php index ce263b6..2425d13 100644 --- a/src/views/circle.blade.php +++ b/src/views/circle.blade.php @@ -1,18 +1,18 @@ -var circleCoordinates_{{ $id }} = ( +var circleCoordinates_{!! $id !!} = ( @foreach ($options['coordinates'] as $key => $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}) + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}) @endforeach ); -var circle_{{ $id }} = new google.maps.Circle({ - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - fillColor: '{{ $options['fillColor'] }}', - fillOpacity: {{ $options['fillOpacity'] }}, - center: circleCoordinates_{{ $id }}, - radius: {{ $options['radius'] }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var circle_{!! $id !!} = new google.maps.Circle({ + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + fillColor: '{!! $options['fillColor'] !!}', + fillOpacity: {!! $options['fillOpacity'] !!}, + center: circleCoordinates_{!! $id !!}, + radius: {!! $options['radius'] !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -circle_{{ $id }}.setMap({{ $options['map'] }}); \ No newline at end of file +circle_{!! $id !!}.setMap({!! $options['map'] !!}); \ No newline at end of file diff --git a/src/views/map.blade.php b/src/views/map.blade.php index 2bc0d0c..99a8052 100644 --- a/src/views/map.blade.php +++ b/src/views/map.blade.php @@ -1,56 +1,56 @@ -
+
\ No newline at end of file diff --git a/src/views/mapper.blade.php b/src/views/mapper.blade.php index d3c4c60..3fffcb9 100644 --- a/src/views/mapper.blade.php +++ b/src/views/mapper.blade.php @@ -1,8 +1,8 @@ - + @foreach ($items as $id => $item) - {{ $item->render($id, $view) }} + {!! $item->render($id, $view) !!} @endforeach diff --git a/src/views/marker.blade.php b/src/views/marker.blade.php index 47ebf5a..099f707 100644 --- a/src/views/marker.blade.php +++ b/src/views/marker.blade.php @@ -1,8 +1,8 @@ @if ($options['user'] && $options['place']) - var service = new google.maps.places.PlacesService({{ $options['map'] }}); + var service = new google.maps.places.PlacesService({!! $options['map'] !!}); var request = { - placeId: '{{ $options['place'] }}' + placeId: '{!! $options['place'] !!}' }; service.getDetails(request, function(placeResult, status) { @@ -13,41 +13,41 @@ @endif -var markerPosition_{{ $id }} = new google.maps.LatLng({{ $options['latitude'] }}, {{ $options['longitude'] }}); +var markerPosition_{!! $id !!} = new google.maps.LatLng({!! $options['latitude'] !!}, {!! $options['longitude'] !!}); -var marker_{{ $id }} = new google.maps.Marker({ - position: markerPosition_{{ $id }}, +var marker_{!! $id !!} = new google.maps.Marker({ + position: markerPosition_{!! $id !!}, @if ($options['user'] && $options['place']) place: { - placeId: '{{ $options['place'] }}', - location: { lat: {{ $options['latitude'] }}, lng: {{ $options['longitude'] }} } + placeId: '{!! $options['place'] !!}', + location: { lat: {!! $options['latitude'] !!}, lng: {!! $options['longitude'] !!} } }, attribution: { source: document.title, webUrl: document.URL }, @endif - title: '{{ $options['title'] }}', - animation: @if (empty($options['animation']) || $options['animation'] == 'NONE') '' @else google.maps.Animation.{{ $options['animation'] }} @endif, + title: '{!! $options['title'] !!}', + animation: @if (empty($options['animation']) || $options['animation'] == 'NONE') '' @else google.maps.Animation.{!! $options['animation'] !!} @endif, @if ($options['symbol']) icon: { - path: google.maps.SymbolPath.{{ $options['symbol'] }}, - scale: {{ $options['scale'] }} + path: google.maps.SymbolPath.{!! $options['symbol'] !!}, + scale: {!! $options['scale'] !!} } @else - icon: '{{ $options['icon'] }}' + icon: '{!! $options['icon'] !!}' @endif }); -bounds.extend(marker_{{ $id }}.position); +bounds.extend(marker_{!! $id !!}.position); -marker_{{ $id }}.setMap({{ $options['map'] }}); +marker_{!! $id !!}.setMap({!! $options['map'] !!}); @if ($options['user'] && $options['place']) - marker_{{ $id }}.addListener('click', function() { + marker_{!! $id !!}.addListener('click', function() { infowindow.setContent('' + placeResult.name + ''); - infowindow.open({{ $options['map'] }}, this); + infowindow.open({!! $options['map'] !!}, this); }); }); @@ -55,12 +55,12 @@ @if (!empty($options['content'])) - var infowindow_{{ $id }} = new google.maps.InfoWindow({ - content: '{{ $options['content'] }}' + var infowindow_{!! $id !!} = new google.maps.InfoWindow({ + content: '{!! $options['content'] !!}' }); - google.maps.event.addListener(marker_{{ $id }}, 'click', function() { - infowindow_{{ $id }}.open({{ $options['map'] }}, marker_{{ $id }}); + google.maps.event.addListener(marker_{!! $id !!}, 'click', function() { + infowindow_{!! $id !!}.open({!! $options['map'] !!}, marker_{!! $id !!}); }); @endif diff --git a/src/views/overlay.blade.php b/src/views/overlay.blade.php index d53bb66..da22bbc 100644 --- a/src/views/overlay.blade.php +++ b/src/views/overlay.blade.php @@ -1,12 +1,12 @@ -var overlayCoordinates_{{ $id }} = new google.maps.LatLngBounds( +var overlayCoordinates_{!! $id !!} = new google.maps.LatLngBounds( @foreach ($options['coordinates'] as $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}), + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}), @endforeach ); -overlay_{{ $id }} = new google.maps.GroundOverlay( - '{{ $options['image'] }}', - overlayCoordinates_{{ $id }} +overlay_{!! $id !!} = new google.maps.GroundOverlay( + '{!! $options['image'] !!}', + overlayCoordinates_{!! $id !!} ); -overlay_{{ $id }}.setMap({{ $options['map'] }}); +overlay_{!! $id !!}.setMap({!! $options['map'] !!}); diff --git a/src/views/polygon.blade.php b/src/views/polygon.blade.php index fa77fc3..6b24f94 100644 --- a/src/views/polygon.blade.php +++ b/src/views/polygon.blade.php @@ -1,17 +1,17 @@ -var polygonCoordinates_{{ $id }} = [ +var polygonCoordinates_{!! $id !!} = [ @foreach ($options['coordinates'] as $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}), + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}), @endforeach ]; -var polygon_{{ $id }} = new google.maps.Polygon({ - paths: polygonCoordinates_{{ $id }}, - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - fillColor: '{{ $options['fillColor'] }}', - fillOpacity: {{ $options['fillOpacity'] }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var polygon_{!! $id !!} = new google.maps.Polygon({ + paths: polygonCoordinates_{!! $id !!}, + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + fillColor: '{!! $options['fillColor'] !!}', + fillOpacity: {!! $options['fillOpacity'] !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -polygon_{{ $id }}.setMap({{ $options['map'] }}); +polygon_{!! $id !!}.setMap({!! $options['map'] !!}); diff --git a/src/views/polyline.blade.php b/src/views/polyline.blade.php index 4203904..e536213 100644 --- a/src/views/polyline.blade.php +++ b/src/views/polyline.blade.php @@ -1,16 +1,16 @@ -var polylineCoordinates_{{ $id }} = [ +var polylineCoordinates_{!! $id !!} = [ @foreach ($options['coordinates'] as $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}), + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}), @endforeach ]; -var polyline_{{ $id }} = new google.maps.Polyline({ - path: polylineCoordinates_{{ $id }}, - geodesic: {{ $options['strokeColor'] ? 'true' : 'false' }}, - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var polyline_{!! $id !!} = new google.maps.Polyline({ + path: polylineCoordinates_{!! $id !!}, + geodesic: {!! $options['strokeColor'] ? 'true' : 'false' !!}, + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -polyline_{{ $id }}.setMap({{ $options['map'] }}); \ No newline at end of file +polyline_{!! $id !!}.setMap({!! $options['map'] !!}); \ No newline at end of file diff --git a/src/views/rectangle.blade.php b/src/views/rectangle.blade.php index c8c2119..832ac80 100644 --- a/src/views/rectangle.blade.php +++ b/src/views/rectangle.blade.php @@ -1,17 +1,17 @@ -var rectangleCoordinates_{{ $id }} = new google.maps.LatLngBounds( +var rectangleCoordinates_{!! $id !!} = new google.maps.LatLngBounds( @foreach ($options['coordinates'] as $key => $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }})@if (count($options['coordinates']) - 1 > $key), @endif + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!})@if (count($options['coordinates']) - 1 > $key), @endif @endforeach ); -var rectangle_{{ $id }} = new google.maps.Rectangle({ - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - fillColor: '{{ $options['fillColor'] }}', - fillOpacity: {{ $options['fillOpacity'] }}, - bounds: rectangleCoordinates_{{ $id }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var rectangle_{!! $id !!} = new google.maps.Rectangle({ + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + fillColor: '{!! $options['fillColor'] !!}', + fillOpacity: {!! $options['fillOpacity'] !!}, + bounds: rectangleCoordinates_{!! $id !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -rectangle_{{ $id }}.setMap({{ $options['map'] }}); +rectangle_{!! $id !!}.setMap({!! $options['map'] !!}); diff --git a/src/views/streetview.blade.php b/src/views/streetview.blade.php index 55a4c62..94d3170 100644 --- a/src/views/streetview.blade.php +++ b/src/views/streetview.blade.php @@ -1,35 +1,35 @@ -
+
\ No newline at end of file From 84d9e6d7dc5e0f08029cb12eb2d842cea36de5ae Mon Sep 17 00:00:00 2001 From: Bradley Cornford Date: Fri, 12 Jun 2015 11:18:53 +0100 Subject: [PATCH 04/40] Updated support for Laravel 5. --- README.md | 8 ++-- composer.json | 3 +- .../Googlmapper/MapperServiceProvider.php | 13 ++++-- src/views/circle.blade.php | 24 +++++------ src/views/map.blade.php | 32 +++++++-------- src/views/mapper.blade.php | 4 +- src/views/marker.blade.php | 40 +++++++++---------- src/views/overlay.blade.php | 12 +++--- src/views/polygon.blade.php | 22 +++++----- src/views/polyline.blade.php | 20 +++++----- src/views/rectangle.blade.php | 22 +++++----- src/views/streetview.blade.php | 20 +++++----- 12 files changed, 113 insertions(+), 107 deletions(-) diff --git a/README.md b/README.md index 9096cc8..68c42c2 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,9 @@ [![Build Status](https://travis-ci.org/bradcornford/Googlmapper.svg?branch=master)](https://travis-ci.org/bradcornford/Googlmapper) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bradcornford/Googlmapper/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/bradcornford/Googlmapper/?branch=master) -Think of Googlmapper as an easy way to integrate Google Maps with Laravel 4, providing a variety of helpers to speed up the utilisation of mapping. These include: +### For Laravel 4.x, check [version 1.0.1](https://github.com/bradcornford/Googlmapper/tree/v1.0.1) + +Think of Googlmapper as an easy way to integrate Google Maps with Laravel, providing a variety of helpers to speed up the utilisation of mapping. These include: - `Mapper::map` - `Mapper::stretview` @@ -22,7 +24,7 @@ Think of Googlmapper as an easy way to integrate Google Maps with Laravel 4, pro Begin by installing this package through Composer. Edit your project's `composer.json` file to require `cornford/googlmapper`. "require": { - "cornford/googlmapper": "1.*" + "cornford/googlmapper": "2.*" } Next, update Composer from the Terminal: @@ -39,7 +41,7 @@ The next step is to introduce the facade. Open `app/config/app.php`, and add a n Finally we need to introduce the configuration files into your application/ - php artisan config:publish cornford/googlmapper + php artisan vendor:publish --provider="Cornford\\Googlmapper\\MapperServiceProvider" That's it! You're all set to go. diff --git a/composer.json b/composer.json index 07684b2..7a00fe9 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,7 @@ } ], "require": { - "php": ">=5.4.0", - "illuminate/support": "4.2.*" + "php": ">=5.4.0" }, "require-dev": { "phpspec/phpspec": "2.0.*@dev", diff --git a/src/Cornford/Googlmapper/MapperServiceProvider.php b/src/Cornford/Googlmapper/MapperServiceProvider.php index 479a4e7..6b1f211 100644 --- a/src/Cornford/Googlmapper/MapperServiceProvider.php +++ b/src/Cornford/Googlmapper/MapperServiceProvider.php @@ -19,7 +19,11 @@ class MapperServiceProvider extends ServiceProvider { */ public function boot() { - $this->package('cornford/googlmapper'); + $configPath = __DIR__ . '/../../config/config.php'; + $this->publishes([$configPath => config_path('googlmapper.php')], 'googlmapper'); + + $viewPath = __DIR__ . '/../../views'; + $this->loadViewsFrom($viewPath, 'googlmapper'); } /** @@ -29,13 +33,14 @@ public function boot() */ public function register() { + $configPath = __DIR__ . '/../../config/config.php'; + $this->mergeConfigFrom($configPath, 'googlmapper'); + $this->app['mapper'] = $this->app->share(function($app) { - $config = $app['config']->get('googlmapper::config'); - return new Mapper( $this->app->view, - $config + $app['config']->get('googlmapper') ); }); } diff --git a/src/views/circle.blade.php b/src/views/circle.blade.php index ce263b6..2425d13 100644 --- a/src/views/circle.blade.php +++ b/src/views/circle.blade.php @@ -1,18 +1,18 @@ -var circleCoordinates_{{ $id }} = ( +var circleCoordinates_{!! $id !!} = ( @foreach ($options['coordinates'] as $key => $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}) + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}) @endforeach ); -var circle_{{ $id }} = new google.maps.Circle({ - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - fillColor: '{{ $options['fillColor'] }}', - fillOpacity: {{ $options['fillOpacity'] }}, - center: circleCoordinates_{{ $id }}, - radius: {{ $options['radius'] }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var circle_{!! $id !!} = new google.maps.Circle({ + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + fillColor: '{!! $options['fillColor'] !!}', + fillOpacity: {!! $options['fillOpacity'] !!}, + center: circleCoordinates_{!! $id !!}, + radius: {!! $options['radius'] !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -circle_{{ $id }}.setMap({{ $options['map'] }}); \ No newline at end of file +circle_{!! $id !!}.setMap({!! $options['map'] !!}); \ No newline at end of file diff --git a/src/views/map.blade.php b/src/views/map.blade.php index 2bc0d0c..99a8052 100644 --- a/src/views/map.blade.php +++ b/src/views/map.blade.php @@ -1,56 +1,56 @@ -
+
\ No newline at end of file diff --git a/src/views/mapper.blade.php b/src/views/mapper.blade.php index d3c4c60..3fffcb9 100644 --- a/src/views/mapper.blade.php +++ b/src/views/mapper.blade.php @@ -1,8 +1,8 @@ - + @foreach ($items as $id => $item) - {{ $item->render($id, $view) }} + {!! $item->render($id, $view) !!} @endforeach diff --git a/src/views/marker.blade.php b/src/views/marker.blade.php index 47ebf5a..099f707 100644 --- a/src/views/marker.blade.php +++ b/src/views/marker.blade.php @@ -1,8 +1,8 @@ @if ($options['user'] && $options['place']) - var service = new google.maps.places.PlacesService({{ $options['map'] }}); + var service = new google.maps.places.PlacesService({!! $options['map'] !!}); var request = { - placeId: '{{ $options['place'] }}' + placeId: '{!! $options['place'] !!}' }; service.getDetails(request, function(placeResult, status) { @@ -13,41 +13,41 @@ @endif -var markerPosition_{{ $id }} = new google.maps.LatLng({{ $options['latitude'] }}, {{ $options['longitude'] }}); +var markerPosition_{!! $id !!} = new google.maps.LatLng({!! $options['latitude'] !!}, {!! $options['longitude'] !!}); -var marker_{{ $id }} = new google.maps.Marker({ - position: markerPosition_{{ $id }}, +var marker_{!! $id !!} = new google.maps.Marker({ + position: markerPosition_{!! $id !!}, @if ($options['user'] && $options['place']) place: { - placeId: '{{ $options['place'] }}', - location: { lat: {{ $options['latitude'] }}, lng: {{ $options['longitude'] }} } + placeId: '{!! $options['place'] !!}', + location: { lat: {!! $options['latitude'] !!}, lng: {!! $options['longitude'] !!} } }, attribution: { source: document.title, webUrl: document.URL }, @endif - title: '{{ $options['title'] }}', - animation: @if (empty($options['animation']) || $options['animation'] == 'NONE') '' @else google.maps.Animation.{{ $options['animation'] }} @endif, + title: '{!! $options['title'] !!}', + animation: @if (empty($options['animation']) || $options['animation'] == 'NONE') '' @else google.maps.Animation.{!! $options['animation'] !!} @endif, @if ($options['symbol']) icon: { - path: google.maps.SymbolPath.{{ $options['symbol'] }}, - scale: {{ $options['scale'] }} + path: google.maps.SymbolPath.{!! $options['symbol'] !!}, + scale: {!! $options['scale'] !!} } @else - icon: '{{ $options['icon'] }}' + icon: '{!! $options['icon'] !!}' @endif }); -bounds.extend(marker_{{ $id }}.position); +bounds.extend(marker_{!! $id !!}.position); -marker_{{ $id }}.setMap({{ $options['map'] }}); +marker_{!! $id !!}.setMap({!! $options['map'] !!}); @if ($options['user'] && $options['place']) - marker_{{ $id }}.addListener('click', function() { + marker_{!! $id !!}.addListener('click', function() { infowindow.setContent('' + placeResult.name + ''); - infowindow.open({{ $options['map'] }}, this); + infowindow.open({!! $options['map'] !!}, this); }); }); @@ -55,12 +55,12 @@ @if (!empty($options['content'])) - var infowindow_{{ $id }} = new google.maps.InfoWindow({ - content: '{{ $options['content'] }}' + var infowindow_{!! $id !!} = new google.maps.InfoWindow({ + content: '{!! $options['content'] !!}' }); - google.maps.event.addListener(marker_{{ $id }}, 'click', function() { - infowindow_{{ $id }}.open({{ $options['map'] }}, marker_{{ $id }}); + google.maps.event.addListener(marker_{!! $id !!}, 'click', function() { + infowindow_{!! $id !!}.open({!! $options['map'] !!}, marker_{!! $id !!}); }); @endif diff --git a/src/views/overlay.blade.php b/src/views/overlay.blade.php index d53bb66..da22bbc 100644 --- a/src/views/overlay.blade.php +++ b/src/views/overlay.blade.php @@ -1,12 +1,12 @@ -var overlayCoordinates_{{ $id }} = new google.maps.LatLngBounds( +var overlayCoordinates_{!! $id !!} = new google.maps.LatLngBounds( @foreach ($options['coordinates'] as $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}), + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}), @endforeach ); -overlay_{{ $id }} = new google.maps.GroundOverlay( - '{{ $options['image'] }}', - overlayCoordinates_{{ $id }} +overlay_{!! $id !!} = new google.maps.GroundOverlay( + '{!! $options['image'] !!}', + overlayCoordinates_{!! $id !!} ); -overlay_{{ $id }}.setMap({{ $options['map'] }}); +overlay_{!! $id !!}.setMap({!! $options['map'] !!}); diff --git a/src/views/polygon.blade.php b/src/views/polygon.blade.php index fa77fc3..6b24f94 100644 --- a/src/views/polygon.blade.php +++ b/src/views/polygon.blade.php @@ -1,17 +1,17 @@ -var polygonCoordinates_{{ $id }} = [ +var polygonCoordinates_{!! $id !!} = [ @foreach ($options['coordinates'] as $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}), + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}), @endforeach ]; -var polygon_{{ $id }} = new google.maps.Polygon({ - paths: polygonCoordinates_{{ $id }}, - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - fillColor: '{{ $options['fillColor'] }}', - fillOpacity: {{ $options['fillOpacity'] }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var polygon_{!! $id !!} = new google.maps.Polygon({ + paths: polygonCoordinates_{!! $id !!}, + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + fillColor: '{!! $options['fillColor'] !!}', + fillOpacity: {!! $options['fillOpacity'] !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -polygon_{{ $id }}.setMap({{ $options['map'] }}); +polygon_{!! $id !!}.setMap({!! $options['map'] !!}); diff --git a/src/views/polyline.blade.php b/src/views/polyline.blade.php index 4203904..e536213 100644 --- a/src/views/polyline.blade.php +++ b/src/views/polyline.blade.php @@ -1,16 +1,16 @@ -var polylineCoordinates_{{ $id }} = [ +var polylineCoordinates_{!! $id !!} = [ @foreach ($options['coordinates'] as $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }}), + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}), @endforeach ]; -var polyline_{{ $id }} = new google.maps.Polyline({ - path: polylineCoordinates_{{ $id }}, - geodesic: {{ $options['strokeColor'] ? 'true' : 'false' }}, - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var polyline_{!! $id !!} = new google.maps.Polyline({ + path: polylineCoordinates_{!! $id !!}, + geodesic: {!! $options['strokeColor'] ? 'true' : 'false' !!}, + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -polyline_{{ $id }}.setMap({{ $options['map'] }}); \ No newline at end of file +polyline_{!! $id !!}.setMap({!! $options['map'] !!}); \ No newline at end of file diff --git a/src/views/rectangle.blade.php b/src/views/rectangle.blade.php index c8c2119..832ac80 100644 --- a/src/views/rectangle.blade.php +++ b/src/views/rectangle.blade.php @@ -1,17 +1,17 @@ -var rectangleCoordinates_{{ $id }} = new google.maps.LatLngBounds( +var rectangleCoordinates_{!! $id !!} = new google.maps.LatLngBounds( @foreach ($options['coordinates'] as $key => $coordinate) - new google.maps.LatLng({{ $coordinate['latitude'] }}, {{ $coordinate['longitude'] }})@if (count($options['coordinates']) - 1 > $key), @endif + new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!})@if (count($options['coordinates']) - 1 > $key), @endif @endforeach ); -var rectangle_{{ $id }} = new google.maps.Rectangle({ - strokeColor: '{{ $options['strokeColor'] }}', - strokeOpacity: {{ $options['strokeOpacity'] }}, - strokeWeight: {{ $options['strokeWeight'] }}, - fillColor: '{{ $options['fillColor'] }}', - fillOpacity: {{ $options['fillOpacity'] }}, - bounds: rectangleCoordinates_{{ $id }}, - editable: {{ $options['editable'] ? 'true' : 'false' }} +var rectangle_{!! $id !!} = new google.maps.Rectangle({ + strokeColor: '{!! $options['strokeColor'] !!}', + strokeOpacity: {!! $options['strokeOpacity'] !!}, + strokeWeight: {!! $options['strokeWeight'] !!}, + fillColor: '{!! $options['fillColor'] !!}', + fillOpacity: {!! $options['fillOpacity'] !!}, + bounds: rectangleCoordinates_{!! $id !!}, + editable: {!! $options['editable'] ? 'true' : 'false' !!} }); -rectangle_{{ $id }}.setMap({{ $options['map'] }}); +rectangle_{!! $id !!}.setMap({!! $options['map'] !!}); diff --git a/src/views/streetview.blade.php b/src/views/streetview.blade.php index 55a4c62..94d3170 100644 --- a/src/views/streetview.blade.php +++ b/src/views/streetview.blade.php @@ -1,35 +1,35 @@ -
+
\ No newline at end of file From 2505ea7f60ac9372a4718e6c8e8bba24dcb94e04 Mon Sep 17 00:00:00 2001 From: Bradley Cornford Date: Mon, 22 Jun 2015 14:57:54 +0100 Subject: [PATCH 05/40] Intergrated marker clusters. --- src/Cornford/Googlmapper/MapperBase.php | 59 ++++++++++++++++++++++++- src/config/config.php | 10 +++++ src/views/map.blade.php | 6 +++ src/views/mapper.blade.php | 6 +++ src/views/marker.blade.php | 1 + 5 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/Cornford/Googlmapper/MapperBase.php b/src/Cornford/Googlmapper/MapperBase.php index e0b112f..89f339d 100644 --- a/src/Cornford/Googlmapper/MapperBase.php +++ b/src/Cornford/Googlmapper/MapperBase.php @@ -552,6 +552,13 @@ abstract class MapperBase implements MappingBaseInterface 'BOUNCE', ]; + /** + * Map marker cluster. + * + * @var boolean + */ + protected $cluster; + /** * Mapping items. * @@ -604,6 +611,7 @@ public function __construct(View $view, array $options = []) $this->setUi(isset($options['ui']) ? $options['ui'] : true); $this->setIcon(isset($options['markers']['icon']) ? $options['markers']['icon'] : ''); $this->setAnimation(isset($options['markers']['animation']) ? $options['markers']['animation'] : self::ANIMATION_NONE); + $this->setCluster(isset($options['cluster']) ? $options['cluster'] : true); } /** @@ -1119,7 +1127,8 @@ protected function getOptions() 'place' => '', 'animation' => $this->getAnimation(), 'symbol' => '', - ] + ], + 'cluster' => $this->getCluster() ]; } @@ -1169,4 +1178,52 @@ public function getItem($item) return isset($this->items[$item]) ? $this->items[$item] : false; } + /** + * Set cluster status. + * + * @param boolean $value + * + * @throws MapperArgumentException + * + * @return void + */ + protected function setCluster($value) + { + if (!is_bool($value)) { + throw new MapperArgumentException('Invalid map cluster setting.'); + } + + $this->cluster = $value; + } + + /** + * Get the cluster status. + * + * @return boolean + */ + protected function getCluster() + { + return $this->cluster; + } + + /** + * Enable cluster. + * + * @return void + */ + public function enableCluster() + { + $this->setCluster(true); + } + + /** + * Disable cluster. + * + * @return void + */ + public function disableCluster() + { + $this->setCluster(false); + } + } \ No newline at end of file diff --git a/src/config/config.php b/src/config/config.php index 01009ea..e3b3674 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -136,4 +136,14 @@ ), + /* + |-------------------------------------------------------------------------- + | Map Marker Cluster + |-------------------------------------------------------------------------- + | + | Enable default Googlmapper map marker cluster. + | + */ + 'cluster' => true, + ); diff --git a/src/views/map.blade.php b/src/views/map.blade.php index 99a8052..8975bb9 100644 --- a/src/views/map.blade.php +++ b/src/views/map.blade.php @@ -18,10 +18,16 @@ function initialize_{!! $id !!}() { var map_{!! $id !!} = new google.maps.Map(document.getElementById('map-canvas-{!! $id !!}'), mapOptions_{!! $id !!}); map_{!! $id !!}.setTilt({!! $options['tilt'] !!}); + var markers = []; + @foreach ($options['markers'] as $key => $marker) {!! $marker->render($key, $view) !!} @endforeach + @if ($options['cluster']) + var markerCluster = new MarkerClusterer(map_{!! $id !!}, markers); + @endif + @foreach ($options['shapes'] as $key => $shape) {!! $shape->render($key, $view) !!} @endforeach diff --git a/src/views/mapper.blade.php b/src/views/mapper.blade.php index 3fffcb9..c1a1040 100644 --- a/src/views/mapper.blade.php +++ b/src/views/mapper.blade.php @@ -1,5 +1,11 @@ +@if ($options['cluster']) + + + +@endif + @foreach ($items as $id => $item) {!! $item->render($id, $view) !!} diff --git a/src/views/marker.blade.php b/src/views/marker.blade.php index 099f707..ab2a31d 100644 --- a/src/views/marker.blade.php +++ b/src/views/marker.blade.php @@ -42,6 +42,7 @@ bounds.extend(marker_{!! $id !!}.position); marker_{!! $id !!}.setMap({!! $options['map'] !!}); +markers.push(marker_{!! $id !!}); @if ($options['user'] && $options['place']) From 6c0f51871a05a7995dca2e983eb66b9569030095 Mon Sep 17 00:00:00 2001 From: Michel LAURENT Date: Tue, 23 Jun 2015 18:22:51 +0200 Subject: [PATCH 06/40] Use environment variable for Google api key instead of setting it in the config file --- src/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/config.php b/src/config/config.php index e3b3674..2feb2df 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -20,7 +20,7 @@ | A Google API key to link Googlmapper to Google's API. | */ - 'key' => 'AIzaSyAtqWsq5Ai3GYv6dSa6311tZiYKlbYT4mw', + 'key' => env('GOOGLE_API_KEY'), /* |-------------------------------------------------------------------------- From 784333e517b432066b2843156136aed361dec9b0 Mon Sep 17 00:00:00 2001 From: Michel LAURENT Date: Tue, 23 Jun 2015 18:28:29 +0200 Subject: [PATCH 07/40] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 68c42c2..7632a96 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,12 @@ The next step is to introduce the facade. Open `app/config/app.php`, and add a n 'Mapper' => 'Cornford\Googlmapper\Facades\Mapper', -Finally we need to introduce the configuration files into your application/ +Finally we need to introduce the configuration files into your application. php artisan vendor:publish --provider="Cornford\\Googlmapper\\MapperServiceProvider" +You also need to set your Google API Key into the `GOOGLE_API_KEY` environment variable. To obtain an API key for your project, visit the [Google developers console](https://console.developers.google.com/). + That's it! You're all set to go. ## Configuration @@ -152,4 +154,4 @@ The `render` method allows all maps to be rendered to the page, this method can ### License -Googlmapper is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) \ No newline at end of file +Googlmapper is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) From 5610338f8e30478470d87cc8ec363ec113c02426 Mon Sep 17 00:00:00 2001 From: Syahril Zulkefli Date: Sun, 28 Jun 2015 22:00:58 +0800 Subject: [PATCH 08/40] Change the class name to be as same as file name --- src/Cornford/Googlmapper/Facades/MapperFacade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cornford/Googlmapper/Facades/MapperFacade.php b/src/Cornford/Googlmapper/Facades/MapperFacade.php index aa9a38e..8c13502 100644 --- a/src/Cornford/Googlmapper/Facades/MapperFacade.php +++ b/src/Cornford/Googlmapper/Facades/MapperFacade.php @@ -2,7 +2,7 @@ use Illuminate\Support\Facades\Facade; -class Mapper extends Facade { +class MapperFacade extends Facade { protected static function getFacadeAccessor() { return 'mapper'; } From c6eec38e0e520b03327736839592d057dc2ce64b Mon Sep 17 00:00:00 2001 From: Syahril Zulkefli Date: Sun, 28 Jun 2015 22:02:00 +0800 Subject: [PATCH 09/40] Change the alias to be as same as file and class name --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 68c42c2..c295e9f 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Once this operation completes, the next step is to add the service provider. Ope The next step is to introduce the facade. Open `app/config/app.php`, and add a new item to the aliases array. - 'Mapper' => 'Cornford\Googlmapper\Facades\Mapper', + 'Mapper' => 'Cornford\Googlmapper\Facades\MapperFacade', Finally we need to introduce the configuration files into your application/ @@ -152,4 +152,4 @@ The `render` method allows all maps to be rendered to the page, this method can ### License -Googlmapper is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) \ No newline at end of file +Googlmapper is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) From 05754e28c93a0c22666e45bc9a2db2a7a051b5db Mon Sep 17 00:00:00 2001 From: Bradley Cornford Date: Mon, 13 Jul 2015 10:08:21 +0100 Subject: [PATCH 10/40] Adding an accessible maps variable for JS manipulation. --- src/config/config.php | 2 +- src/views/map.blade.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/config/config.php b/src/config/config.php index 2feb2df..57c7392 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -20,7 +20,7 @@ | A Google API key to link Googlmapper to Google's API. | */ - 'key' => env('GOOGLE_API_KEY'), + 'key' => env('GOOGLE_API_KEY', 'AIzaSyAtqWsq5Ai3GYv6dSa6311tZiYKlbYT4mw'), /* |-------------------------------------------------------------------------- diff --git a/src/views/map.blade.php b/src/views/map.blade.php index 8975bb9..14cdc2d 100644 --- a/src/views/map.blade.php +++ b/src/views/map.blade.php @@ -2,6 +2,8 @@