Skip to content

Commit 673e423

Browse files
committed
Merge branch 'release/1.5.0'
2 parents 60dbe1d + 7892549 commit 673e423

6 files changed

Lines changed: 2641 additions & 4778 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ A `google.maps.Circle` replacement for Mapbox GL JS, rendering a "spherical cap"
4646
```javascript
4747
var myCircle = new MapboxCircle({lat: 39.984, lng: -75.343}, 25000, {
4848
editable: true,
49+
minRadius: 1500,
4950
fillColor: '#29AB87'
5051
}).addTo(myMapboxGlMap);
5152

@@ -71,6 +72,8 @@ myCircle.on('contextmenu', function (mapMouseEvent) {
7172
- `radius` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Meter radius
7273
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
7374
- `options.editable` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Enable handles for changing center and radius (optional, default `false`)
75+
- `options.minRadius` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Minimum radius on user interaction (optional, default `10`)
76+
- `options.maxRadius` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Maximum radius on user interaction (optional, default `1100000`)
7477
- `options.strokeColor` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Stroke color (optional, default `'#000000'`)
7578
- `options.strokeWeight` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Stroke weight (optional, default `0.5`)
7679
- `options.strokeOpacity` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Stroke opacity (optional, default `0.75`)
@@ -181,6 +184,10 @@ Returns **{sw: {lat: [number](https://developer.mozilla.org/en-US/docs/Web/JavaS
181184

182185
## Changelog
183186

187+
### v. 1.5.0
188+
189+
- Added support for passing `minRadius` and `maxRadius` options to _MapboxCircle_ constructor
190+
184191
### v. 1.4.3
185192

186193
- Bug fix for handling _map.setStyle_ updates

example/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ const editableOpts = {
6161
strokeOpacity: 0.85,
6262
fillColor: '#29AB87',
6363
fillOpacity: 0.2,
64+
minRadius: 100,
65+
maxRadius: 500000,
6466
debugEl: document.body.appendChild(document.createElement('div'))
6567
};
6668

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140

141141
var editableCircleOpts = {
142142
editable: true,
143+
minRadius: 50,
143144
debugEl: document.getElementById('debug')
144145
};
145146

lib/main.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ if (window && typeof window.MapboxCircle === 'function') {
2121
* @example
2222
* var myCircle = new MapboxCircle({lat: 39.984, lng: -75.343}, 25000, {
2323
* editable: true,
24+
* minRadius: 1500,
2425
* fillColor: '#29AB87'
2526
* }).addTo(myMapboxGlMap);
2627
*
@@ -126,7 +127,7 @@ class MapboxCircle {
126127

127128
/** @param {number} newRadius Meter radius. */
128129
set radius(newRadius) {
129-
this._currentRadius = Math.min(Math.max(this._minRadius, newRadius), this._maxRadius);
130+
this._currentRadius = Math.min(Math.max(this.options.minRadius, newRadius), this.options.maxRadius);
130131
this._updateCircle();
131132
this._animate();
132133
}
@@ -150,6 +151,8 @@ class MapboxCircle {
150151
* @param {number} radius Meter radius
151152
* @param {?Object} options
152153
* @param {?boolean} [options.editable=false] Enable handles for changing center and radius
154+
* @param {?number} [options.minRadius=10] Minimum radius on user interaction
155+
* @param {?number} [options.maxRadius=1100000] Maximum radius on user interaction
153156
* @param {?string} [options.strokeColor='#000000'] Stroke color
154157
* @param {?number} [options.strokeWeight=0.5] Stroke weight
155158
* @param {?number} [options.strokeOpacity=0.75] Stroke opacity
@@ -170,8 +173,6 @@ class MapboxCircle {
170173

171174
/** @const {[number,number]} */ this._lastCenterLngLat = [centerLng, centerLat];
172175
/** @const {[number,number]} */ this._currentCenterLngLat = [centerLng, centerLat];
173-
/** @const {number} */ this._minRadius = 1e1;
174-
/** @const {number} */ this._maxRadius = 1.1e6;
175176
/** @const {number} */ this._lastRadius = Math.round(radius);
176177
/** @const {number} */ this._currentRadius = Math.round(radius);
177178
/** @const {Object} */ this.options = _.extend({
@@ -182,6 +183,8 @@ class MapboxCircle {
182183
fillColor: '#FB6A4A',
183184
fillOpacity: 0.25,
184185
refineStroke: false,
186+
minRadius: 10,
187+
maxRadius: 1.1e6,
185188
properties: {},
186189
debugEl: null
187190
}, options);

0 commit comments

Comments
 (0)