Skip to content

Commit

Permalink
feat(build): 'maxBounds' attribute renamed as 'maxbounds'.
Browse files Browse the repository at this point in the history
  • Loading branch information
tombatossals committed Dec 27, 2013
1 parent 5fb3005 commit b2f541c
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ module.exports = function(grunt) {
'src/directives/paths.js',
'src/directives/controls.js',
'src/directives/eventBroadcast.js',
'src/directives/maxBounds.js',
'src/directives/maxbounds.js',
'src/services/leafletData.js',
'src/services/leafletMapDefaults.js',
'src/services/leafletEvents.js',
Expand Down
14 changes: 7 additions & 7 deletions dist/angular-leaflet-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ angular.module("leaflet-directive", []).directive('leaflet', function ($q, leafl
scope: {
center: '=center',
defaults: '=defaults',
maxBounds: '=maxbounds',
maxbounds: '=maxbounds',
bounds: '=bounds',
markers: '=markers',
legend: '=legend',
Expand Down Expand Up @@ -39,8 +39,8 @@ angular.module("leaflet-directive", []).directive('leaflet', function ($q, leafl
genDispatchMapEvent = leafletEvents.genDispatchMapEvent,
mapEvents = leafletEvents.getAvailableMapEvents();

// If we are going to set maxBounds, undefine the minZoom property
if (isDefined(scope.maxBounds)) {
// If we are going to set maxbounds, undefine the minZoom property
if (isDefined(scope.maxbounds)) {
defaults.minZoom = undefined;
}

Expand Down Expand Up @@ -964,17 +964,17 @@ angular.module("leaflet-directive").directive('maxbounds', function ($log, leafl


controller.getMap().then(function(map) {
leafletScope.$watch("maxBounds", function (maxBounds) {
leafletScope.$watch("maxbounds", function (maxbounds) {
// Unset any previous maxbounds
map.setMaxBounds();
map.fire("zoomlevelschange");

if (!isValidBounds(maxBounds)) {
if (!isValidBounds(maxbounds)) {
return;
}
map.setMaxBounds( [
[ maxBounds.southWest.lat, maxBounds.southWest.lng ],
[ maxBounds.northEast.lat, maxBounds.northEast.lng ]
[ maxbounds.southWest.lat, maxbounds.southWest.lng ],
[ maxbounds.northEast.lat, maxbounds.northEast.lng ]
]);
});
});
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-leaflet-directive.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/leaflet-directive.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ We have much more possibilities than showing a simple map, but this will need th
* [_defaults_ attribute](https://github.com/tombatossals/angular-leaflet-directive/blob/master/doc/defaults-attribute.md)
* [_center_ attribute](https://github.com/tombatossals/angular-leaflet-directive/blob/master/doc/center-attribute.md)
* [_bounds_ attribute](https://github.com/tombatossals/angular-leaflet-directive/blob/master/doc/bounds-attribute.md)
* [_maxBounds_ attribute](https://github.com/tombatossals/angular-leaflet-directive/blob/master/doc/maxBounds-attribute.md)
* [_maxbounds_ attribute](https://github.com/tombatossals/angular-leaflet-directive/blob/master/doc/maxbounds-attribute.md)
14 changes: 7 additions & 7 deletions doc/maxBounds-attribute.md → doc/maxbounds-attribute.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'maxBounds' Attribute Documentation
'maxbounds' Attribute Documentation
===================================

This sub-directive needs the **leaflet** main directive, so it is normaly used as an attribute of the *leaflet* tag, like this:

```
<leaflet maxBounds="maxBounds"></leaflet>
<leaflet maxbounds="maxbounds"></leaflet>
```

It will map an object _maxBounds_ of our controller scope with the corresponding object on our leaflet directive isolated scope. It's not a bidirectional relationship, only the changes made to our _maxBounds_ object on the controller scope will affect the map, but no viceversa.
It will map an object _maxbounds_ of our controller scope with the corresponding object on our leaflet directive isolated scope. It's not a bidirectional relationship, only the changes made to our _maxbounds_ object on the controller scope will affect the map, but no viceversa.

```
$scope.maxBounds = {
$scope.maxbounds = {
southWest: {
lat:51.508742458803326,
lng: -0.087890625,
Expand All @@ -27,14 +27,14 @@ Defining the bounds is a little complex, so we have a helper which will allow us

```
app.controller("DemoController", [ "$scope", "leafletBoundsHelpers", function($scope, leafletBoundsHelpers) {
var maxBounds = leafletBoundsHelpers.createBoundsFromArray([
var maxbounds = leafletBoundsHelpers.createBoundsFromArray([
[ 51.508742458803326, -0.087890625 ],
[ 51.508742458803326, -0.087890625 ]
]);
angular.extend($scope, {
maxBounds: maxBounds
maxbounds: maxbounds
});
});
```

And that's all, we can see how the map is affected when we change the _maxBounds_ scope values, like [this example](http://tombatossals.github.io/angular-leaflet-directive/examples/maxbounds-example.html).
And that's all, we can see how the map is affected when we change the _maxbounds_ scope values, like [this example](http://tombatossals.github.io/angular-leaflet-directive/examples/maxbounds-example.html).
14 changes: 7 additions & 7 deletions examples/maxbounds-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
};

angular.extend($scope, {
maxBounds: {},
maxbounds: {},
defaults: {
minZoom: 4
}
Expand All @@ -62,13 +62,13 @@
</head>
<body ng-controller="DemoController">
<form>
<button ng-click="maxBounds=regions.london">London region</button>
<button ng-click="maxBounds=regions.lisbon">Lisbon region</button>
<button ng-click="maxBounds=regions.warszawa">Warszawa region</button>
<button ng-click="maxBounds={}">Unset maxbounds</button>
<button ng-click="maxbounds=regions.london">London region</button>
<button ng-click="maxbounds=regions.lisbon">Lisbon region</button>
<button ng-click="maxbounds=regions.warszawa">Warszawa region</button>
<button ng-click="maxbounds={}">Unset maxbounds</button>
</form>

<leaflet maxBounds="maxBounds" defaults="defaults"></leaflet>
<p ng-show="maxBounds.northEast" class="result">Maxbounds: NE(lat: {{ maxBounds.northEast.lat }}, lng: {{ maxBounds.northEast.lng }}) SW(lat: {{ maxBounds.southWest.lat }}, lng: {{ maxBounds.southWest.lng }})</p>
<leaflet maxbounds="maxbounds" defaults="defaults"></leaflet>
<p ng-show="maxbounds.northEast" class="result">Maxbounds: NE(lat: {{ maxbounds.northEast.lat }}, lng: {{ maxbounds.northEast.lng }}) SW(lat: {{ maxbounds.southWest.lat }}, lng: {{ maxbounds.southWest.lng }})</p>
</body>
</html>
6 changes: 3 additions & 3 deletions src/directives/leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ angular.module("leaflet-directive", []).directive('leaflet', function ($q, leafl
scope: {
center: '=center',
defaults: '=defaults',
maxBounds: '=maxbounds',
maxbounds: '=maxbounds',
bounds: '=bounds',
markers: '=markers',
legend: '=legend',
Expand Down Expand Up @@ -35,8 +35,8 @@ angular.module("leaflet-directive", []).directive('leaflet', function ($q, leafl
genDispatchMapEvent = leafletEvents.genDispatchMapEvent,
mapEvents = leafletEvents.getAvailableMapEvents();

// If we are going to set maxBounds, undefine the minZoom property
if (isDefined(scope.maxBounds)) {
// If we are going to set maxbounds, undefine the minZoom property
if (isDefined(scope.maxbounds)) {
defaults.minZoom = undefined;
}

Expand Down
8 changes: 4 additions & 4 deletions src/directives/maxBounds.js → src/directives/maxbounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ angular.module("leaflet-directive").directive('maxbounds', function ($log, leafl


controller.getMap().then(function(map) {
leafletScope.$watch("maxBounds", function (maxBounds) {
leafletScope.$watch("maxbounds", function (maxbounds) {
// Unset any previous maxbounds
map.setMaxBounds();
map.fire("zoomlevelschange");

if (!isValidBounds(maxBounds)) {
if (!isValidBounds(maxbounds)) {
return;
}
map.setMaxBounds( [
[ maxBounds.southWest.lat, maxBounds.southWest.lng ],
[ maxBounds.northEast.lat, maxBounds.northEast.lng ]
[ maxbounds.southWest.lat, maxbounds.southWest.lng ],
[ maxbounds.northEast.lat, maxbounds.northEast.lng ]
]);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Directive: leaflet', function() {
defaults: {
minZoom: 4,
},
maxBounds: {
maxbounds: {
southWest: {
lat: 52.14823737817847,
lng: 20.793685913085934
Expand All @@ -36,7 +36,7 @@ describe('Directive: leaflet', function() {
}
}
});
var element = angular.element('<leaflet defaults="defaults" maxBounds="maxBounds"></leaflet>');
var element = angular.element('<leaflet defaults="defaults" maxbounds="maxbounds"></leaflet>');
element = $compile(element)($rootScope);
var leafletMap;
leafletData.getMap().then(function(map) {
Expand Down

0 comments on commit b2f541c

Please sign in to comment.