Skip to content

Commit

Permalink
Bug fix for #50
Browse files Browse the repository at this point in the history
  • Loading branch information
mblomdahl committed Oct 22, 2017
1 parent b2df3e5 commit 09a19f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ Returns **[MapboxCircle](#mapboxcircle)**
**Parameters**

- `map` **mapboxgl.Map** Target map for adding and initializing circle Mapbox GL layers/data/listeners.
- `before` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Layer ID to insert the circle layers before, else they will be appended to
the end of the layers array (optional, default `undefined`)
- `before` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Layer ID to insert the circle layers before; explicitly pass `null` to
get the circle assets appended at the end of map-layers array (optional, default `'waterway-label'`)

Returns **[MapboxCircle](#mapboxcircle)**

Expand Down
11 changes: 7 additions & 4 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1039,12 +1039,15 @@ class MapboxCircle {

/**
* @param {mapboxgl.Map} map Target map for adding and initializing circle Mapbox GL layers/data/listeners.
* @param {?string} [before=undefined] Layer ID to insert the circle layers before, else they will be appended to
* the end of the layers array
* @param {?string} [before='waterway-label'] Layer ID to insert the circle layers before; explicitly pass `null` to
* get the circle assets appended at the end of map-layers array
* @return {MapboxCircle}
* @public
*/
addTo(map, before) {
if (typeof before === 'undefined') {
before = 'waterway-label';
}
const addCircleAssetsOnMap = () => {
map.addSource(this._circleSourceId, this._getCircleMapSource());

Expand All @@ -1056,10 +1059,10 @@ class MapboxCircle {
if (this.options.editable) {
map.addSource(this._circleHandlesSourceId, this._getHandlesMapSource());

map.addLayer(this._getCircleCenterHandleLayer(), before);
map.addLayer(this._getCircleCenterHandleLayer());
this._bindCenterHandleListeners(map);

map.addLayer(this._getCircleRadiusHandlesLayer(), before);
map.addLayer(this._getCircleRadiusHandlesLayer());
this._bindRadiusHandlesListeners(map);

this.on('centerchanged', this._onCenterChanged).on('radiuschanged', this._onRadiusChanged);
Expand Down

0 comments on commit 09a19f4

Please sign in to comment.